Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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;

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.

like image 718
Mojtaba Tajik Avatar asked Nov 21 '10 20:11

Mojtaba Tajik


1 Answers

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.

like image 58
GolezTrol Avatar answered Nov 12 '22 20:11

GolezTrol