How can I make my console application receive window messages?
I need to write a message handler in my console application that handles received messages. For example, I register WM_Test and send it by to my console application like this:
var
H: THandle;
begin
H:= FindWindow('ConsoleWindowClass', nil);
PostMessage(H, WM_Test, 0, 0);
end;
开发者_JAVA百科
Now I want when I receive this message in my console application to show a message box.
Can I use PeekMessage or AllocateHWND in console programs?
I know that I can do this work with a pipe, but I want know whether I can do this with window message.
Yes you can. Use AllocateHWND to create a window handle. Then, you can set various properties (like the name), so you can find it using FindWindow.
精彩评论