[SOLVED] Process Messages in console application lazarus / 34-Windows ---------------------------------------------------------------------- Dibo · 2011-06-11 21:09 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: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i 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 ---------------------------------------------------------------------- typo · 2011-06-11 21:29 Place the caret over Application.ProcessMessages on code editor. Then use Alt + Up to find the declaration and Ctrl + Shift + Down to find the procedure of function. (If I understand your question) ---------------------------------------------------------------------- Dibo · 2011-06-11 21:41 I tried that but stopped on WidgetSet.AppProcessMessages which is abtract (I should search it in lazarus source). But I found solution. I must peek messages in loop by my self: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   while true do begin    if PeekMessage(Msg,0,0,0,0) then    begin      GetMessage(Msg,0,0,0);      TranslateMessage(Msg);      DispatchMessage(Msg);    end;    Sleep(10);  end; Sorry for false alarm, I am not familiar in console applications. Regards