Recent

Author Topic: FindWindow seems to not work with Lazarus 4.4 = FPC 3.3.2 - Windows 11  (Read 239 times)

LeoBruno

  • Jr. Member
  • **
  • Posts: 64
Hi:

I'm having trouble with this simple FindWindow example

Code: Pascal  [Select][+][-]
  1.   { TForm1 }
  2.  
  3.   TForm1 = class(TForm)
  4.     Button1: TButton;
  5.     procedure Button1Click(Sender: TObject);
  6.   private
  7.  
  8.   public
  9.  
  10.   end;
  11.  
  12. var
  13.   Form1: TForm1;
  14.  
  15. implementation
  16.  
  17. {$R *.lfm}
  18.  
  19. { TForm1 }
  20.  
  21. procedure TForm1.Button1Click(Sender: TObject);
  22. var
  23.   HandleId: HWND;
  24. begin
  25.   HandleId := FindWindow('TForm1', 'Form1');
  26.   if HandleId <> 0 then
  27.     ShowMessage('Found');
  28. end;
  29.  

The window is not found.
The same code ported to delphi is working fine, so I don't think that it should be windows 11 related.

Any tips?
Lazarus 4.4 FPC 3.2.2 Windows - MetaDarkStyle

rca

  • Full Member
  • ***
  • Posts: 118
Re: FindWindow seems to not work with Lazarus 4.4 = FPC 3.3.2 - Windows 11
« Reply #1 on: December 06, 2025, 12:41:30 am »
Tested and working on Windows 11, as follows (ClassName is nil):

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. var
  3.   HandleId: HWND;
  4. begin
  5.   HandleId := FindWindow(nil, 'Form1');
  6.   if HandleId <> 0 then
  7.     ShowMessage('Found');
  8. end;

 

TinyPortal © 2005-2018