Hi,
I have console application for windows which waiting for message sent from other application with SendMessage (so it's blocking until my application response). I have simple loop which waiting for this message. Console application create dummy non visible window (CreateWindowEx()) which handle this message:
program Test;
uses Windows;
var
ServiceWnd: HWND;
ServiceWndClass: Windows.TWndClass;
{ Queue message handling }
function ServiceWndProc(HWindow: HWnd; Message: UINT; WParam: WPARAM; LParam: LPARAM): Longint;stdcall;
begin
Result:=0;
{ Client response }
if (Message=MyMessage) then
begin
Writeln('Got Message');
Result := 1;
end else
{ Default }
Result:=DefWindowProc(HWindow,Message,WParam,LParam);
end;
begin
ServiceWndClass.lpfnWndProc := @ServiceWndProc;
ServiceWndClass.hInstance := HInstance;
ServiceWndClass.lpszClassName := 'DemoClass';
ServiceWnd := CreateWindowEx(WS_EX_TOOLWINDOW, PChar('DemoClass'),
'Demo', WS_POPUP {!0}, 0, 0, 0, 0, 0, 0, HInstance, nil);
if (ServiceWnd=0) then
Exit;
while True do
Sleep(10);
DestroyWindow(ServiceWnd);
end;
With this code, application which send message to me freezing until I terminate my console application. It seems that my console don't send response correctly to SendMessage caller. If I add Application.ProcesMessages to my loop then it works fine but I must add LCL and interfaces to my simply console application. What ProcessMessages do that caller get response?
Regards