delphi 在线程中运行窗体


本文整理自网络,侵删。

 -------------------------

var
wClass: TWndClass;
Msg: TMsg;

function WindowProc(hWnd,Msg,wParam,lParam:Integer):Integer; stdcall;
begin
if Msg = WM_DESTROY then PostQuitMessage(0)
else if Msg = WM_lBUTTONDOWN then DoSomething;
Result := DefWindowProc(hWnd,Msg,wParam,lParam);
end;

function MyWindow(Ptr: Pointer):Longint;stdcall;
begin
wClass.lpszClassName:= 'CN';
wClass.lpfnWndProc := @WindowProc;
wClass.hInstance := hInstance;
wClass.hbrBackground:= 1;

RegisterClassA(wClass);

CreateWindow(wClass.lpszClassName,'My Window',
WS_OVERLAPPEDWINDOW or WS_VISIBLE,
10,10,530,100,0,0,hInstance,nil);
while GetMessage(Msg,0,0,0) do
DispatchMessage(Msg);
end;

begin
CreateThread(nil, 0, @MyWindow, nil, 0, thrID);
end.

相关阅读 >>

Delphi 获取cpu占用时间

Delphi pagecontrol.ttabsheet与drivecombobox.items同步

Delphi thread类的创建及使用(关于线程函数的传递例子)

Delphi tgauge类的定义在哪个单元中定义的?

Delphi fdmemtable中如何在已有的字段数据集上加入字段

Delphi listview 实现进度条显示

Delphi7 写过卡巴主动防御服务端

Delphi 将 html 代码直接加入到 twebbrowser 组件中去

Delphi link() 精简打开网址

Delphi 取得文件版本

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...