【发布时间】:2011-04-08 00:10:26
【问题描述】:
我试图在 2 个单独的项目之间发送消息,但我的问题是我试图让接收器在 TThread 对象内运行,但 WndProc 不能从对象内工作,必须是一个函数,无论如何要创建TThread 中的一个窗口,可以处理线程内的消息?
这就是我的意思
function TDataThread.WindowProc(hwnd: HWND; uMsg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
begin
Result := 0;
case uMsg of
WM_DATA_AVA: MessageBox(0, 'Data Avaibale', 'Test', 0);
else Result := DefWindowProc(hwnd, uMsg, wParam, lParam);
end;
end;
Procedure TDataThread.Create(const Title:String);
begin
HAppInstance := HInstance;
with WndClass do
begin
Style := 0;
lpfnWndProc := @WindowProc; //The Error Lies here (Variable Required)
cbClsExtra := 0;
cbWndExtra := 0;
hInstance := HAppInstance;
hIcon := 0;
hCursor := LoadCursor(0, IDC_ARROW);
hbrBackground := COLOR_WINDOW;
lpszMenuName := nil;
lpszClassName := 'TDataForm';
end;
Windows.RegisterClass(WndClass);
MainForm := CreateWindow('TDataForm', PAnsiChar(Title), WS_DLGFRAME , XPos, YPos, 698, 517, 0, 0, hInstance, nil);
end;
我需要一个表单,以便我可以从另一个应用程序获取它的句柄,如果需要,使用 FindWindow 和 FindWindowEx
【问题讨论】: