timer.nsi 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. !pragma warning disable 8000 ; "Page instfiles not used, no sections will be executed!"
  17. Function OnTimer
  18. SendMessage $PROGBAR ${PBM_GETPOS} 0 0 $1
  19. ${If} $1 = 100
  20. SendMessage $PROGBAR ${PBM_SETPOS} 0 0
  21. ${Else}
  22. SendMessage $PROGBAR ${PBM_DELTAPOS} 10 0
  23. ${EndIf}
  24. FunctionEnd
  25. Function OnTimer2
  26. SendMessage $PROGBAR2 ${PBM_GETPOS} 0 0 $1
  27. ${If} $1 = 100
  28. SendMessage $PROGBAR2 ${PBM_SETPOS} 0 0
  29. ${Else}
  30. SendMessage $PROGBAR2 ${PBM_DELTAPOS} 5 0
  31. ${EndIf}
  32. FunctionEnd
  33. Function OnTimer3
  34. SendMessage $PROGBAR3 ${PBM_GETPOS} 0 0 $1
  35. ${If} $1 >= 100
  36. ${NSD_KillTimer} OnTimer3
  37. MessageBox MB_OK "Timer 3 killed"
  38. ${Else}
  39. SendMessage $PROGBAR3 ${PBM_DELTAPOS} 2 0
  40. ${EndIf}
  41. FunctionEnd
  42. Function OnClick
  43. Pop $0
  44. ${NSD_KillTimer} OnTimer
  45. FunctionEnd
  46. Function OnClick2
  47. Pop $0
  48. ${NSD_KillTimer} OnTimer2
  49. FunctionEnd
  50. Function nsDialogsPage
  51. nsDialogs::Create 1018
  52. Pop $DIALOG
  53. ${NSD_CreateLabel} 0u 0u 100% 9u "nsDialogs timer example"
  54. Pop $TEXT
  55. ${NSD_CreateProgressBar} 0u 10u 100% 12u ""
  56. Pop $PROGBAR
  57. ${NSD_CreateButton} 0u 25u 100u 14u "Kill Timer 1"
  58. Pop $BUTTON
  59. ${NSD_OnClick} $BUTTON OnClick
  60. ${NSD_CreateProgressBar} 0u 52u 100% 12u ""
  61. Pop $PROGBAR2
  62. SendMessage $PROGBAR2 ${PBM_SETBARCOLOR} 0 0x0000FF ; No visual styles
  63. SendMessage $PROGBAR2 ${PBM_SETSTATE} ${PBST_ERROR} 0 ; Vista+
  64. ${NSD_CreateButton} 0u 67u 100u 14u "Kill Timer 2"
  65. Pop $BUTTON2
  66. ${NSD_OnClick} $BUTTON2 OnClick2
  67. ${NSD_CreateProgressBar} 0u 114u 100% 12u ""
  68. Pop $PROGBAR3
  69. ${NSD_CreateTimer} OnTimer 1000
  70. ${NSD_CreateTimer} OnTimer2 100
  71. ${NSD_CreateTimer} OnTimer3 200
  72. nsDialogs::Show
  73. FunctionEnd
  74. Section
  75. SectionEnd