7

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.

Rob Kennedy
  • 161,384
  • 21
  • 275
  • 467
Mojtaba Tajik
  • 1,725
  • 16
  • 34

1 Answers1

5

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.

GolezTrol
  • 114,394
  • 18
  • 182
  • 210