• inno 实现水波特效


      安装Inno Setup时如果选择了水波效果插件(如下图),将在Inno Setup的安装目录下自带有水波特效的例子,如路径:C:Program Files (x86)Inno Setup 5Examples下的WaterLib_Example.iss。

      

       

      以下是我在原例子的基础上修改得到的非增强版可用的精简代码:

      1 ; 脚本由 Inno Setup 脚本向导 生成!
      2 ; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档!
      3 #include "compiler:WaterLib.iss"
      4 
      5 #define MyAppName "我的程序"
      6 #define MyAppVersion "1.5"
      7 #define MyAppPublisher "我的公司"
      8 #define MyAppURL "http://www.example.com/"
      9 #define MyAppExeName "MyProg.exe"
     10 
     11 [Setup]
     12 ; 注: AppId的值为单独标识该应用程序。
     13 ; 不要为其他安装程序使用相同的AppId值。
     14 ; (生成新的GUID,点击 工具|在IDE中生成GUID。)
     15 AppId={{F40EA292-5A4E-41EB-9819-7D426D45A468}
     16 AppName={#MyAppName}
     17 AppVersion={#MyAppVersion}
     18 ;AppVerName={#MyAppName} {#MyAppVersion}
     19 AppPublisher={#MyAppPublisher}
     20 AppPublisherURL={#MyAppURL}
     21 AppSupportURL={#MyAppURL}
     22 AppUpdatesURL={#MyAppURL}
     23 DefaultDirName={pf}{#MyAppName}
     24 DisableProgramGroupPage=yes
     25 OutputBaseFilename=WaterExp
     26 Compression=lzma
     27 SolidCompression=yes
     28 DisableWelcomePage=no
     29 WizardImageFile=compiler:WizModernImage-Is.bmp
     30 WizardSmallImageFile=compiler:WizModernSmallImage-Is.bmp
     31 [Languages]
     32 Name: "chinesesimp"; MessagesFile: "compiler:Default.isl"
     33 
     34 [Tasks]
     35 Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
     36 
     37 [Files]
     38 ;Source: "C:Program Files (x86)Inno Setup 5ExamplesMyProg.exe"; DestDir: "{app}"; Flags: ignoreversion
     39 Source: compiler:InnoCallback.dll; DestDir: {tmp}; Flags: dontcopy noencryption
     40 ;Source: demo.bmp; DestDir: {tmp}; Flags: dontcopy noencryption
     41 ; 注意: 不要在任何共享系统文件上使用“Flags: ignoreversion”
     42 
     43 [Icons]
     44 Name: "{commonprograms}{#MyAppName}"; Filename: "{app}{#MyAppExeName}"
     45 Name: "{commondesktop}{#MyAppName}"; Filename: "{app}{#MyAppExeName}"; Tasks: desktopicon
     46 
     47 [Code]
     48 
     49 Const
     50   DrawTextMoveDemo = '动态移动演示'; 
     51   
     52 type
     53  TTimerProc = procedure(H: LongWord; MSG: LongWord; idEvent: LongWord; dwTime: LongWord);
     54 function WrapTimerProc(CallBack: TTimerProc; ParamCount: Integer): LongWord; external 'InnoCallback@files:InnoCallBack.dll stdcall';
     55 function SetTimer(hWnd: LongWord; nIDEvent, uElapse: LongWord; lpTimerFunc: LongWord): LongWord; external 'SetTimer@user32.dll stdcall';
     56 
     57 var
     58   MoveB_X, MoveT_Y: Integer;
     59   DrawBitmapDemo: TBitmap;
     60   WaterHandle:Integer;
     61   
     62 procedure MyTimerProc(H: LongWord; MSG: LongWord; idEvent:LongWord; dwTime:LongWord);
     63 begin
     64   MoveT_Y := MoveT_Y + 1;
     65   If MoveT_Y >= WizardForm.WizardBitmapImage.Height then MoveT_Y := 0;
     66   WaterDrawText(WaterHandle, 1, 50, MoveT_Y, DrawTextMoveDemo);
     67 
     68   MoveB_X := MoveB_X + 1;
     69   If MoveB_X >= WizardForm.WizardBitmapImage.Width then MoveB_X := 0 - DrawBitmapDemo.Width;
     70   WaterDrawBitmap(WaterHandle, 1, MoveB_X, 80, DrawBitmapDemo.Handle, True,  clDefault);
     71 end;
     72 
     73 procedure InitializeWizard();
     74 var
     75   F: AnsiString;
     76   TimerCallBack: LongWord;
     77 begin
     78   WaterSupportAuthor(True);
     79   //支持本人作品, 建议开启标识显示.
     80   //只有开启该功能后, 才可以使用WaterDraw****相关API的功能
     81 
     82   //创建水波特效
     83   F:= ExpandConstant('{tmp}WizardImage.bmp');
     84   WizardForm.WizardBitmapImage.Bitmap.SaveToFile(F);
     85   WaterHandle := WaterInit(WizardForm.WelcomePage.Handle, 2, 2);
     86   WaterSetBounds(WaterHandle, WizardForm.WizardBitmapImage.Left, WizardForm.WizardBitmapImage.Top, WizardForm.WizardBitmapImage.Width, WizardForm.WizardBitmapImage.Height);
     87   WaterSetFile(WaterHandle, AnsiString(F));
     88   WaterSetActive(WaterHandle, True);
     89   DeleteFile(F);
     90 
     91   //竖向移动的文本
     92   MoveT_Y := 0;
     93   WaterDrawTextBrush(WaterHandle, 1, clBlack, bsClear);
     94   WaterDrawTextFont(WaterHandle, 1, '宋体', 12, clYellow, 134);
     95   WaterDrawText(WaterHandle, 1, 50, MoveT_Y, DrawTextMoveDemo);
     96   
     97   //横行移动的位图
     98   MoveB_X := 0;
     99   DrawBitmapDemo:= TBitmap.Create;
    100   DrawBitmapDemo.LoadFromFile(ExpandConstant('{commonappdata}MicrosoftUser Account Picturesguest.bmp'));
    101   //ExtractTemporaryFile('demo.bmp');
    102   //DrawBitmapDemo.LoadFromFile(ExpandConstant('{tmp}demo.bmp'));
    103   WaterDrawBitmap(WaterHandle, 1, MoveB_X, 80, DrawBitmapDemo.Handle, True, clDefault);
    104   
    105   //创建动态显示文本或位图的定时器
    106   TimerCallBack := WrapTimerProc(@MyTimerProc, 4);
    107   SetTimer(0, 0, 100, TimerCallBack);
    108 end;
    109 
    110 procedure CurPageChanged(CurPageID: Integer);
    111 begin
    112   Case CurPageID of
    113     wpWelcome : WaterSetParentWindow(WaterHandle, WizardForm.WelcomePage.Handle);  //将水波移动到另一个句柄上
    114     wpFinished: WaterSetParentWindow(WaterHandle, WizardForm.FinishedPage.Handle); //将水波移动到另一个句柄上
    115   end;
    116 end;
    117 
    118 //释放所有水波对象
    119 procedure DeinitializeSetup();
    120 begin
    121   WaterAllFree;
    122 end;

     效果如下:

  • 相关阅读:
    程序设计课程技巧小总结
    《大学之路》读后感(1)
    《世界是数字的》读后感(4)
    《世界是数字的》读后感(3)
    《世界是数字的》读后感(2)
    《世界是数字的》读后感(1)——第一部分 硬件
    独立思考的能力——《不要等到毕业以后》读后感(2)
    迷茫且鉴定——《不要等到毕业以后》读后感(1)
    HashTable HashMap区分
    使用media query 来实现响应式设计
  • 原文地址:https://www.cnblogs.com/hbcppcdr/p/6252491.html
Copyright © 2020-2023  润新知