WaterLib_Example.iss 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. ; 脚本由 Inno Setup 脚本向导 生成!
  2. ; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档!
  3. #include "compiler:WaterLib.iss"
  4. [Setup]
  5. ; 注: AppId的值为单独标识该应用程序。
  6. ; 不要为其他安装程序使用相同的AppId值。
  7. ; (生成新的GUID,点击 工具|在IDE中生成GUID。)
  8. AppId={{CCE7261A-7B8C-4CCA-A4A6-B8048C5BEA9D}
  9. AppName=我的程序
  10. AppVerName=我的程序 1.5
  11. AppPublisher=我的公司
  12. AppPublisherURL=http://www.example.com/
  13. AppSupportURL=http://www.example.com/
  14. AppUpdatesURL=http://www.example.com/
  15. DefaultDirName={pf}\我的程序
  16. DefaultGroupName=我的程序
  17. OutputDir=userdocs:Inno Setup Examples Output
  18. OutputBaseFilename=setup
  19. Compression=lzma
  20. SolidCompression=true
  21. WizardImageFile=compiler:WizModernImage-Is.bmp
  22. [Tasks]
  23. Name: desktopicon; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm:AdditionalIcons}; Flags: unchecked
  24. [Files]
  25. Source: compiler:Examples\MyProg.exe; DestDir: {app}; Flags: ignoreversion
  26. ;如果不是使用本人增强版本INNO,则使用定时回调插件
  27. #ifndef ISVersion
  28. Source: InnoCallback.dll; DestDir: {tmp}; Flags: dontcopy noencryption
  29. #endif
  30. [Code]
  31. #ifndef ISVersion
  32. type
  33. TTimerProc = procedure(H: LongWord; MSG: LongWord; idEvent: LongWord; dwTime: LongWord);
  34. function WrapTimerProc(CallBack: TTimerProc; ParamCount: Integer): LongWord;
  35. external 'InnoCallback@files:InnoCallBack.dll stdcall';
  36. function SetTimer(hWnd: LongWord; nIDEvent, uElapse: LongWord; lpTimerFunc: LongWord): LongWord;
  37. external 'SetTimer@user32.dll stdcall';
  38. #endif
  39. Const
  40. DrawTextDemo = '文本在水波中的演示';
  41. DrawTextMoveDemo = '动态移动演示';
  42. var
  43. MoveB_X, MoveT_Y: Integer;
  44. DT_X, DT_Y: Integer;
  45. DB_X, DB_Y: Integer;
  46. DrawBitmapDemo: TBitmap;
  47. DrawMoveBtn: Array[1..4] Of TButton;
  48. WaterHandle:Integer;
  49. #ifdef ISVersion
  50. Timer: TTimer;
  51. #endif
  52. //手动移动操作
  53. Procedure DrawMoveBtnClick(Sender: TObject);
  54. Begin
  55. Case TButton(Sender).Tag of
  56. 1:
  57. Begin
  58. DT_X := DT_X - 1;
  59. DB_X := DB_X - 1;
  60. End;
  61. 2:
  62. Begin
  63. DT_Y := DT_Y - 1;
  64. DB_Y := DB_Y - 1;
  65. End;
  66. 3:
  67. Begin
  68. DT_Y := DT_Y + 1;
  69. DB_Y := DB_Y + 1;
  70. End;
  71. 4:
  72. Begin
  73. DT_X := DT_X + 1;
  74. DB_X := DB_X + 1;
  75. End;
  76. End;
  77. //移动文本
  78. WaterDrawText(WaterHandle, 0, DT_X, DT_Y, DrawTextDemo);
  79. //移动图片
  80. WaterDrawBitmap(WaterHandle, 0, DB_X, DB_Y, DrawBitmapDemo.Handle, True, clDefault);
  81. End;
  82. #ifdef ISVersion
  83. procedure Timer_OnTimer(Sender: TObject);
  84. Begin
  85. MoveT_Y := MoveT_Y + 1;
  86. If MoveT_Y >= WizardForm.WizardBitmapImage.Height then MoveT_Y := 0;
  87. WaterDrawText(WaterHandle, 1, 50, MoveT_Y, DrawTextMoveDemo);
  88. MoveB_X := MoveB_X + 1;
  89. If MoveB_X >= WizardForm.WizardBitmapImage.Width then MoveB_X := 0 - DrawBitmapDemo.Width;
  90. WaterDrawBitmap(WaterHandle, 1, MoveB_X, 80, DrawBitmapDemo.Handle, True, clDefault);
  91. End;
  92. #else
  93. procedure MyTimerProc(H: LongWord; MSG: LongWord; idEvent:LongWord; dwTime:LongWord);
  94. begin
  95. MoveT_Y := MoveT_Y + 1;
  96. If MoveT_Y >= WizardForm.WizardBitmapImage.Height then MoveT_Y := 0;
  97. WaterDrawText(WaterHandle, 1, 50, MoveT_Y, DrawTextMoveDemo);
  98. MoveB_X := MoveB_X + 1;
  99. If MoveB_X >= WizardForm.WizardBitmapImage.Width then MoveB_X := 0 - DrawBitmapDemo.Width;
  100. WaterDrawBitmap(WaterHandle, 1, MoveB_X, 80, DrawBitmapDemo.Handle);
  101. end;
  102. #endif
  103. procedure InitializeWizard();
  104. var
  105. F: AnsiString;
  106. #ifndef ISVersion
  107. TimerCallBack: LongWord;
  108. #endif
  109. begin
  110. WaterSupportAuthor(True);
  111. //支持本人作品, 建议开启标识显示.
  112. //只有开启该功能后, 才可以使用WaterDraw****相关API的功能
  113. F:= ExpandConstant('{tmp}\WizardImage.bmp');
  114. WizardForm.WizardBitmapImage.Bitmap.SaveToFile(F);
  115. WaterHandle := WaterInit(WizardForm.WelcomePage.Handle, 2, 2);
  116. WaterSetBounds(WaterHandle, WizardForm.WizardBitmapImage.Left, WizardForm.WizardBitmapImage.Top, WizardForm.WizardBitmapImage.Width, WizardForm.WizardBitmapImage.Height);
  117. WaterSetFile(WaterHandle, AnsiString(F));
  118. WaterSetActive(WaterHandle, True);
  119. DeleteFile(F);
  120. //创建动态显示文本或位图的定时器
  121. #ifdef ISVersion
  122. Timer := TTimer.Create(WizardForm);
  123. Timer.OnTimer := @Timer_OnTimer;
  124. Timer.Interval := 100;
  125. Timer.Enabled := True;
  126. #else
  127. TimerCallBack := WrapTimerProc(@MyTimerProc, 4);
  128. SetTimer(0, 0, 100, TimerCallBack);
  129. #endif
  130. //创建手动操作移动按钮
  131. DrawMoveBtn[1] := TButton.Create(WizardForm);
  132. With DrawMoveBtn[1] Do
  133. Begin
  134. Tag := 1;
  135. Caption := '左移';
  136. Parent := WizardForm;
  137. Width := 30;
  138. Left := WizardForm.WizardBitmapImage.Width + 10;
  139. Top := WizardForm.WizardBitmapImage.Height div 2;
  140. OnClick := @DrawMoveBtnClick;
  141. End;
  142. DrawMoveBtn[2] := TButton.Create(WizardForm);
  143. With DrawMoveBtn[2] Do
  144. Begin
  145. Tag := 2;
  146. Caption := '上移';
  147. Parent := WizardForm;
  148. Width := 30;
  149. Left := WizardForm.WizardBitmapImage.Width + 40;
  150. Top := WizardForm.WizardBitmapImage.Height div 2 - 25;
  151. OnClick := @DrawMoveBtnClick;
  152. End;
  153. DrawMoveBtn[3] := TButton.Create(WizardForm);
  154. With DrawMoveBtn[3] Do
  155. Begin
  156. Tag := 3;
  157. Caption := '下移';
  158. Parent := WizardForm;
  159. Width := 30;
  160. Left := WizardForm.WizardBitmapImage.Width + 40;
  161. Top := WizardForm.WizardBitmapImage.Height div 2 + 25;
  162. OnClick := @DrawMoveBtnClick;
  163. End;
  164. DrawMoveBtn[4] := TButton.Create(WizardForm);
  165. With DrawMoveBtn[4] Do
  166. Begin
  167. Tag :=4;
  168. Caption := '右移';
  169. Parent := WizardForm;
  170. Width := 30;
  171. Left := WizardForm.WizardBitmapImage.Width + 70;
  172. Top := WizardForm.WizardBitmapImage.Height div 2;
  173. OnClick := @DrawMoveBtnClick;
  174. End;
  175. //静态显示的文本
  176. DT_X := 20;
  177. DT_Y := 50;
  178. WaterDrawTextBrush(WaterHandle, 0, clBlack, bsClear);
  179. WaterDrawTextFont(WaterHandle, 0, '宋体', 9, clRed, 134);
  180. WaterDrawText(WaterHandle, 0, DT_X, DT_Y, DrawTextDemo);
  181. //静态显示的位图
  182. DB_X := 50;
  183. DB_Y := 160;
  184. DrawBitmapDemo:= TBitmap.Create;
  185. DrawBitmapDemo.LoadFromFile(ExpandConstant('{commonappdata}\Microsoft\User Account Pictures\guest.bmp'));
  186. WaterDrawBitmap(WaterHandle, 0, DB_X, DB_Y, DrawBitmapDemo.Handle, True, clDefault);
  187. //竖向移动的文本
  188. MoveT_Y := 0;
  189. WaterDrawTextBrush(WaterHandle, 1, clBlack, bsClear);
  190. WaterDrawTextFont(WaterHandle, 1, '宋体', 12, clYellow, 134);
  191. WaterDrawText(WaterHandle, 1, 50, MoveT_Y, DrawTextMoveDemo);
  192. //横行移动的位图
  193. MoveB_X := 0;
  194. WaterDrawBitmap(WaterHandle, 1, MoveB_X, 80, DrawBitmapDemo.Handle, True, clDefault);
  195. end;
  196. procedure CurPageChanged(CurPageID: Integer);
  197. begin
  198. Case CurPageID of
  199. wpWelcome : WaterSetParentWindow(WaterHandle, WizardForm.WelcomePage.Handle); //将水波移动到另一个句柄上
  200. wpFinished: WaterSetParentWindow(WaterHandle, WizardForm.FinishedPage.Handle); //将水波移动到另一个句柄上
  201. end;
  202. end;
  203. //释放所有水波对象
  204. procedure DeinitializeSetup();
  205. begin
  206. WaterAllFree;
  207. end;