• DeWeb : 制作图片轮换效果



    演示:http://www.web0000.com/slide.dw

    源代码:http://www.web0000.com/media/source/slide.zip

    一、新建一个DLL
    二、除第一行外,更改源码为

    uses
      ShareMem,  SysUtils,  Forms,  Messages,  StdCtrls,
      Variants,  Windows,  Classes,
      unit1 in 'unit1.pas' {Form1};
    
    {$R *.res}
    type
      PdwGetEvent=function (ACtrl:TComponent;AData:String):string; StdCall;
    var
      DLLApp    : TApplication;
      DLLScreen : TScreen;
    function dwLoad(AParams:String;AApp:TApplication;AScreen:TScreen):TForm;stdcall;
    var
         AForm     : TForm1;
    begin
         //
         Application    := AApp;
         Screen         := AScreen;
         AForm          := TForm1.Create(nil);
         AForm.Hint     := AParams;
         Result         := AForm;
    end;
    
    procedure DLLUnloadProc(dwReason: DWORD);
    begin
         if dwReason = DLL_PROCESS_DETACH then begin
              Application    := DLLApp; //恢复
              Screen         := DLLScreen;
         end;
    end;
    
    exports
         dwLoad;
    
    begin
         DLLApp    := Application; //保存 DLL 中初始的 Application
         DLLScreen := Screen;
         DLLProc   := @DLLUnloadProc;//保证卸载时恢复原Application
         DLLUnloadProc(DLL_PROCESS_DETACH);
    end.


    三、新建一个Form,保存为unit1.pas. 窗体名称为Form1
    四、在合适位置旋转1个TImage、1个TTimer和3个TButton
    五、在TTimer的OnTimer事件中写入

    procedure TForm1.Timer_SlideTimer(Sender: TObject);
    begin
         //set tag
         if Timer_Slide.Tag<3 then begin
              Timer_Slide.Tag     := Timer_Slide.Tag + 1;
         end else begin
              Timer_Slide.Tag     := 1;
         end;
         //change the image src
         Image_MN.Hint  := '{"src":"/media/images/mn/'+IntToStr(Timer_Slide.Tag)+'.jpg"}';
    end;


    六、3个按钮的Caption分别为1,2,3,
    设置OnEnter事件代码为

    procedure TForm1.Button1Enter(Sender: TObject);
    begin
         //Stop the slide timer
         Timer_Slide.DesignInfo   := 0;
         //set tag
         Timer_Slide.Tag          := StrToIntDef(TButton(Sender).Caption,1);
         //change the image src
         Image_MN.Hint  := '{"src":"/media/images/mn/'+IntToStr(Timer_Slide.Tag)+'.jpg"}';
    
    end;

    设置OnExit事件代码为

    procedure TForm1.Button1Exit(Sender: TObject);
    begin
         //start the slide timer
         Timer_Slide.DesignInfo   := 1;
    
    end;

    这样基本上就可以了。



  • 相关阅读:
    利用正則表達式排除特定字符串
    js面向对象编程:this究竟代表什么?
    js调用父级frame中的方法
    Cocos2d-x动画工具类
    BZOJ 2466 中山市选2009 树 高斯消元+暴力
    Android Intent Scheme URLs攻击
    XML基础(一)
    【Life】 Never Too Late, Just Do it Better!
    代理模式
    HDU--Elevator(水题)
  • 原文地址:https://www.cnblogs.com/maxxua/p/14249004.html
Copyright © 2020-2023  润新知