我想在线程中接收其它应用程序发送来的自定义消息,程序如下:在Excute中,
Threadtest.Excute();
begin
while ...
begin
if GetMessage(.., self.handle, WM_USER+100, WM_USER+100) then
printGraph;//(这是一个打印图形的过程)
end;
end
启动线程后,程序运行没有任何结果,而我如果单独将if语句放在一个按钮中就可以打出图形,为什么?
Threadtest.Excute();
begin
while ...
begin
if GetMessage(.., self.handle, WM_USER+100, WM_USER+100) then
printGraph;//(这是一个打印图形的过程)
end;
end
启动线程后,程序运行没有任何结果,而我如果单独将if语句放在一个按钮中就可以打出图形,为什么?
函数可能需要同步。
GetMessage难道有什么特性吗?我看API介绍其返回值为三类:0(接收到的是WM_QUIT),-1(出错),非零(接收到WM_QUIT之外的消息)。可是起返回类型又是BOOL型,如何让GetMessage每次都能又返回值?
高手快说话啊!
你跟踪进去GetMessage看看
HWND hWnd, // handle of window
UINT wMsgFilterMin, // first message
UINT wMsgFilterMax // last message
);
ParameterslpMsgPoints to an MSG structure that receives message information from the thread's message queue. hWndIdentifies the window whose messages are to be retrieved. One value has a special meaning: Value Meaning
NULL GetMessage retrieves messages for any window that belongs to the calling thread and thread messages posted to the calling thread via PostThreadMessage.
wMsgFilterMinSpecifies the integer value of the lowest message value to be retrieved. wMsgFilterMaxSpecifies the integer value of the highest message value to be retrieved
if PeekMessage(Msg,0,0,0,PM_NOREMOVE) then
if Msg.message = MM_MESSAGE then
Form1.Edit1.Text := 'catch message';
end;