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. ASP.NET MVC4应用程序配置跨域访问

    开发框架是使用webapi做后台,HTML5做前台,通过ajax调用webapi后台,返回json结果. 用的编译器是visual Studio2013,下面是配置方法 1.web.config文件 ...

  2. 设置ul的指定li 样式

    设置ul的最后li 的样式 .custom-consumerIndex .card-content .list-block ul li:last-child .item-inner { border- ...

  3. pycharm 输入法光标跟随

  4. 解决Exception in thread "main" java.nio.BufferOverflowException报错

    学习bytebuffer时,写了简单的demo报错: 错误的提示:Exception in thread "main" java.nio.BufferOverflowExcepti ...

  5. ES6参数默认值

    参数默认值 1.首先,来看一下es5中的函数默认值 var a = a || 10; var b = b || "none" // 当a的值或者b的值为undefined时,根据逻 ...

  6. Neural Network Programming - Deep Learning with PyTorch with deeplizard.

    PyTorch Prerequisites - Syllabus for Neural Network Programming Series PyTorch先决条件 - 神经网络编程系列教学大纲 每个 ...

  7. element UI 下拉菜单滚动监听(vue指令)

    直接看代码吧,可以直接粘贴此代码到你的编辑器中看效果. <template> <div class="page-component"> <div cl ...

  8. 2018-计算机系机试(第二批)-A-最大数

    单点时限: 1.0 sec 内存限制: 256 MB 输入 n 个整数,输出其中最大数的值. 例如:3 个整数 1 ,2 和 6 的最大值是 6 . 输入格式 每一行的第一个数是 n (1≤n≤20 ...

  9. C#action和func的使用

    以前我都是通过定义一个delegate来写委托的,但是最近看一些外国人写的源码都是用action和func方式来写,当时感觉对这很陌生所以看起源码也觉得陌生,所以我就花费时间来学习下这两种方式,然后发 ...

  10. 转 Postman访问Webapi的Get/Post/Put/Delte请求

    Postman访问Webapi的Get/Post/Put/Delte请求 2018年07月26日 15:04:46 DoNotWorkOvertime 阅读数:348 标签: WebApiPostma ...