timer.nsi 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. !include LogicLib.nsh
  2. !include nsDialogs.nsh
  3. !include WinMessages.nsh
  4. Name "nsDialogs Timer Example"
  5. OutFile "nsDialogs Timer Example.exe"
  6. XPStyle on
  7. RequestExecutionLevel user
  8. Var DIALOG
  9. Var TEXT
  10. Var PROGBAR
  11. Var PROGBAR2
  12. Var PROGBAR3
  13. Var BUTTON
  14. Var BUTTON2
  15. Page custom nsDialogsPage
  16. Function OnTimer
  17. SendMessage $PROGBAR ${PBM_GETPOS} 0 0 $1
  18. ${If} $1 = 100
  19. SendMessage $PROGBAR ${PBM_SETPOS} 0 0
  20. ${Else}
  21. SendMessage $PROGBAR ${PBM_DELTAPOS} 10 0
  22. ${EndIf}
  23. FunctionEnd
  24. Function OnTimer2
  25. SendMessage $PROGBAR2 ${PBM_GETPOS} 0 0 $1
  26. ${If} $1 = 100
  27. SendMessage $PROGBAR2 ${PBM_SETPOS} 0 0
  28. ${Else}
  29. SendMessage $PROGBAR2 ${PBM_DELTAPOS} 5 0
  30. ${EndIf}
  31. FunctionEnd
  32. Function OnTimer3
  33. SendMessage $PROGBAR3 ${PBM_GETPOS} 0 0 $1
  34. ${If} $1 >= 100
  35. ${NSD_KillTimer} OnTimer3
  36. MessageBox MB_OK "Timer 3 killed"
  37. ${Else}
  38. SendMessage $PROGBAR3 ${PBM_DELTAPOS} 2 0
  39. ${EndIf}
  40. FunctionEnd
  41. Function OnClick
  42. Pop $0
  43. ${NSD_KillTimer} OnTimer
  44. FunctionEnd
  45. Function OnClick2
  46. Pop $0
  47. ${NSD_KillTimer} OnTimer2
  48. FunctionEnd
  49. Function nsDialogsPage
  50. nsDialogs::Create 1018
  51. Pop $DIALOG
  52. ${NSD_CreateLabel} 0u 0u 100% 9u "nsDialogs timer example"
  53. Pop $TEXT
  54. ${NSD_CreateProgressBar} 0u 10u 100% 12u ""
  55. Pop $PROGBAR
  56. ${NSD_CreateButton} 0u 25u 100u 14u "Kill Timer 1"
  57. Pop $BUTTON
  58. ${NSD_OnClick} $BUTTON OnClick
  59. ${NSD_CreateProgressBar} 0u 52u 100% 12u ""
  60. Pop $PROGBAR2
  61. SendMessage $PROGBAR2 ${PBM_SETBARCOLOR} 0 0x0000FF ; No visual styles
  62. SendMessage $PROGBAR2 ${PBM_SETSTATE} ${PBST_ERROR} 0 ; Vista+
  63. ${NSD_CreateButton} 0u 67u 100u 14u "Kill Timer 2"
  64. Pop $BUTTON2
  65. ${NSD_OnClick} $BUTTON2 OnClick2
  66. ${NSD_CreateProgressBar} 0u 114u 100% 12u ""
  67. Pop $PROGBAR3
  68. ${NSD_CreateTimer} OnTimer 1000
  69. ${NSD_CreateTimer} OnTimer2 100
  70. ${NSD_CreateTimer} OnTimer3 200
  71. nsDialogs::Show
  72. FunctionEnd
  73. Section
  74. SectionEnd