开发者

How can I make my console application receive window messages?

开发者 https://www.devze.com 2023-01-26 09:07 出处:网络
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:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号