您的位置:首页 > 编程语言 > Delphi

DELPHI 7 学习---------定时器

2013-01-22 08:29 176 查看
目的:完成一段时间定时

主要内容:界面设计,动态导入DLL。实现数字的透明显示及到时提醒

 

一、界面过程:

 1.设置窗体的 TransparentColor属性为 True;

2.设置窗体的 TransparentColorValue属性为某一颜色,如clBlack

3.窗体放置一个Tlabel元件,设置其Color属性值为窗体的 TransparentColorValue

 

二、DLL导入过程:

1.动态导入一个模式对话框函数,用以提醒用户

代码:

type THS=function(lpText:PwideChar;lpCaption:PWideChar;uType:Cardinal):Integer; cdecl ; //DLL中函数原型

var d:TDateTime; m,n:integer;

 dllHandle:THandle;

 msgbox:THS;

begin

  d:=now-startTime;

  label1.Caption:=formatDateTime('nn:ss',d);

  m:=MinuteOf(d);

  n:=SecondOf(d);

  if (m=10) and (n=0) then begin                  //设定时间(10分钟)到,提醒用户

  

  Timer1.Enabled:=false;

   dllHandle:=LoadLibrary('two.dll');           // two.dll外部函数

   if dllHandle<>0 then try                            

     msgbox:=GetProcAddress(dllHandle,'twofunction'); //取得函数地址

     if @msgbox<>nil then

       MsgBox('Time''s up!','',MB_OK );            //调用函数

   finally

    FreeLibrary(dllHandle);

   end

  else  Action_Play.Execute;

  end;

end;

2.静态导入DLL。完成MP3音乐的播放

所有函数封装在mp3.dll中

格式如下:

      function InitMp3(hInstance, hWnd, DisplayW, DisplayH, bands: integer): integer; stdcall; external 'mp3.dll' name 'pvInitMp3';

     

        procedure FreeMp3; stdcall; external 'mp3.dll' name 'pvFreeMp3';

        procedure GetMp3Info(pFileName: PChar; pFreq, pLen: pointer); stdcall; external 'mp3.dll' name'pvGetMp3Info';

        function PlayMp3(pFileName: PChar): integer; stdcall; external 'mp3.dll' name 'pvPlayMp3';

        procedure StopMp3; stdcall; external 'mp3.dll' name 'pvStopMp3';

        procedure PauseMp3; stdcall; external 'mp3.dll' name 'pvPauseMp3';

        procedure ResumeMp3; stdcall; external 'mp3.dll' name 'pvResumeMp3';

 

 注:该mp3.dll 源于网络
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: