unit Unit2;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls; type
TForm2 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
FWorkHandle: THandle;
procedure WorkWindowProc(var message: TMessage);
public
{ Public declarations }
end; var
Form2: TForm2; const
WM_PROGRESS = WM_USER + $A;
EventTimer1 = 1020;
EventTimer2 = 1021; implementation {$R *.dfm} procedure TForm2.Button1Click(Sender: TObject);
begin
PostMessage(FWorkHandle, WM_PROGRESS, 0, 0);
end; procedure TForm2.FormCreate(Sender: TObject);
begin
FWorkHandle := AllocateHWnd(WorkWindowProc);
SetTimer(FWorkHandle, EventTimer1, 1000, nil);
SetTimer(FWorkHandle, EventTimer2, 100, nil);
end; procedure TForm2.FormDestroy(Sender: TObject);
begin
KillTimer(FWorkHandle, EventTimer1);
KillTimer(FWorkHandle, EventTimer2);
DeallocateHWnd(FWorkHandle);
end; procedure TForm2.WorkWindowProc(var message: TMessage);
begin
case message.Msg of
WM_PROGRESS:
Caption := 'hello WM_BURNPROGRESS';
WM_COPYDATA:
Caption := 'hello WM_COPYDATA';
WM_TIMER:
begin
case message.WParam of
EventTimer1:
Caption := 'hello WM_TIMER Event1 ' + IntToStr(GetTickCount);
EventTimer2:
Caption := 'hello WM_TIMER Event2 ' + IntToStr(GetTickCount);
end;
end;
else
//Dispatch(message);
end;
end; end.

  

AllocateHWnd SetTimer API的更多相关文章

  1. SetTimer API函数

    位于user32.dll中,可以每隔一段时间执行一段时间执行一件事的时候,可以使用它. 使用定时器,通常告诉Windows一个时间间隔,然后Windows以此时间间隔周期性触发程序. 发送WM_TIM ...

  2. DELPHI下API简述(1800个API)

    DELPHI下API简述 http://zero.cnbct.org/show.asp?id=144 auxGetDevCaps API 获取附属设备容量 auxGetNumDevs API 返回附属 ...

  3. Callback函数详解(我感觉,回掉函数的本质是函数指针,在业务做循环处理的时候,调用一下通知外部)

    2010年的最后一天了,转载一篇自己认为还不错的文章与大家分享.希望对大家有所帮助. 一,回调函数 我们经常在C++设计时通过使用回调函数可以使有些应用(如定时器事件回调处理.用回调函数记录某操作进度 ...

  4. 第二篇 界面开发 (Android学习笔记)

    第二篇 界面开发 第5章 探索界面UI元素 ●The Android View Class     ●△Widget设计步骤 需要修改三个XML,以及一个class: 1)第一个xml是布局XML文件 ...

  5. 回调函数(callback) python / c++ 演示

    什么是回调函数? 我们绕点远路来回答这个问题. 编程分为两类:系统编程(system programming)和应用编程(application programming).所谓系统编程,简单来说,就是 ...

  6. Microsoft Win32 to Microsoft .NET Framework API Map

    Microsoft Win32 to Microsoft .NET Framework API Map .NET Development (General) Technical Articles   ...

  7. 英文不好也能快速"记忆" API

    英文不好不要紧,把API函数导入打字练习类软件,即是练习打字速度,提高编程效率:也能短时间记忆API. 坚持每天打一遍,约2小时,连续打两周,会对API有很好的记忆,此方法是结合英文学习方法!以下是W ...

  8. SetTimer函数的用法

    什么时候我们需要用到SetTimer函数呢?当你需要每个一段时间执行一件事的的时候就需要使用SetTimer函数 了.使用定时器的方法比较简单,通常告诉WINDOWS一个时间间隔,然后WINDOWS以 ...

  9. Thread message loop for a thread with a hidden window? Make AllocateHwnd safe

    Thread message loop for a thread with a hidden window? I have a Delphi 6 application that has a thre ...

随机推荐

  1. Java中的静态方法和实例方法的调用的理解(不同的类下的方法调用)

    public class MethodCall { public static void main(String[] args) { Test.sayStatic(); Test test = new ...

  2. VS2017 nlog源码查看报错

    最近下载nlog的源码学习,打开解决方案以后无法编译. C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Sd ...

  3. Android作业

    一.设置跑马灯功能   使用滚动字幕显示标题“请选择你喜欢哪种花” <?xml version="1.0" encoding="utf-8"?>&l ...

  4. Scrapy的使用

    建立好项目以后,在项目文件内scrapy会搭好框架,我们只需要按照框架设置. 先定义Item    它是保存爬取到的数据的容器,其使用方法和python的字典类似,并且提供了额外保护机制来避免拼写错误 ...

  5. Python_随机序列生成_白噪声

    本文介绍如何利用Python自行生成随机序列,实现了 Whichmann / Hill 生成器. 参考: [1]Random Number Generation and Monte Carlo Met ...

  6. Android第二次作业

    另一成员链接:https://www.cnblogs.com/2575590018dqy/p/10053353.html

  7. spring cloud_1_mm_ribbon

    ji接上文 ribbon做请求分发负载均衡 ribbon 配置: server.port=9999 spring.application.name=ribbon-consumer #stores.ri ...

  8. ansible常用模块用法

    ansible常用模块用法 2015-07-21 10:25 24458人阅读 评论(1) 收藏 举报  分类: Linux(44)   ansible 版权声明:本文为博主原创文章,未经博主允许不得 ...

  9. Gravatar 头像使用

    Gravatar :如果在Gravatar的服务器上放置了你自己的头像,那么在任何支持Gravatar的blog或者留言本上留言时,只要提供你与这个头像关联的email地址,就能够显示出你的Grava ...

  10. 2018 CCPC网络赛 hdu6444 Neko's loop

    题目描述: Neko has a loop of size n.The loop has a happy value ai on the i−th(0≤i≤n−1) grid. Neko likes ...