[SOLVED] EnumWindows doesnt Finish lazarus / 34-Windows ---------------------------------------------------------------------- Cliff48 · 2015-07-02 00:07 The Following code used to work, but now EnumWindows never finishes / returns. Code: [Select]function AllWindows(hW: THandle; List: Integer): Boolean; stdcall; var l: LongInt; found: Boolean = false; wCaption: String[255]; begin Result := True; l := SendMessage(hW, WM_GETTEXT, 254, LongInt(@wCaption[1])); if l > 0 then begin wCaption[0] := char(l); FormEnum.cb1.Items.add(wCaption); end; showMessage(IntToHex(hW, 8) + ' ' + IntToStr(l)); end; procedure TFormEnum.FormCreate(Sender: TObject); begin ShowMessage('Enum Windows'); enumWindows(@AllWindows, 0); showmessage('Pause'); end; EnumW calls the AllWindows Function many times, but after it is done, the system is left in a loop and ShowMessage('Pause') is never executed. This is a Function I have in a working program and the above was created to isolate/demonstrate the problem I'm having. One thing different, is that the working program is compiled with {$mode Objfpc}{$H+} but to compile the above I had to change to: {$mode Delphi}{$H+} which I dont understand why. I assume I have done something silly, but I cant see it. Any help would be appreciated. ---------------------------------------------------------------------- Cliff48 · 2015-07-02 00:32 I added if IsWindowVisible(hW) then before the SendMessage(hW, WM_GETTEXT ......... Obviously Windows hangs waiting for a response from a non-visible window. Still curious as to why I needed to compile in Delphi mode tho. ---------------------------------------------------------------------- typo · 2015-07-02 00:37 You need to replace mode ObjFPC by mode Delphi: Code: [Select]//{$mode objfpc} {$mode delphi}{$H+} ---------------------------------------------------------------------- Cliff48 · 2015-07-02 01:29 Quote from: typo on July 02, 2015, 02:37:33 amYou need to replace mode ObjFPC by mode Delphi: Code: [Select]//{$mode objfpc} {$mode delphi}{$H+} Can someone explain why i had to change ... and why it compiled with objfpc previously? ---------------------------------------------------------------------- atroesch · 2025-11-27 19:12 i know a really old thread but i got the same question.. why it only compiles in delphi Mode? ---------------------------------------------------------------------- PascalDragon · 2025-11-27 20:10 Quote from: atroesch on November 27, 2025, 08:12:10 pmi know a really old thread but i got the same question.. why it only compiles in delphi Mode? I assume the error message is the following: Code: [Select]tenumwin.pp(25,26) Error: Incompatible type for arg no. 1: Got "
", expected "