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 源于网络
主要内容:界面设计,动态导入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 源于网络
相关文章推荐
- 51学习之定时器中断的两种方式——查询和中断
- STM32系统学习——TIM(基本定时器)
- 单片机入门学习十三 STM32单片机学习十 通用定时器
- stm32的定时器学习
- 浅谈Delphi过程与函数01 - 零基础入门学习Delphi20
- C#多线程学习(五) 多线程的自动管理(定时器)
- 界面设计02 - 零基础入门学习Delphi43
- Delphi学习使用资源文件 - DLL 中的资源文件[组图]
- 基于stm32f103zet6的定时器的学习3(定时器产生4路PWM)
- 关于delphi 中 Sender的学习
- Delphi面向对象学习随笔一:类与对象的关系(转)
- Delphi学习心得
- MSP430单片机定时器学习笔记
- delphi真接用COM组件连接数据库学习
- 《Delphi 算法与数据结构》学习与感悟[3]: 获取一个字节中非空位的个数
- 学习使用Delphi for android 调用Java类库
- 《Delphi 算法与数据结构》学习与感悟[9]: 循环链表
- Contiki学习笔记3:定时器
- 【Delphi学习】关于SQL Server 2008的数据备份及还原
- delphi 最专业的学习论坛,全英文哦,可以练英文阅读 http://www.delphigroups.info/forum/2/