Recent

Author Topic: Dialogue FileOpen position chose  (Read 608 times)

marcio2003

  • Jr. Member
  • **
  • Posts: 69
Dialogue FileOpen position chose
« on: May 25, 2023, 11:02:40 am »
Hi,
How i can chose position to FileOpen dialogue on Windows 10 using Lazarus_2_0_10.
Always I want it positioned in desktop center.
Thanks.
Lazarus 2.0.10 Windows 10 64bits

ASerge

  • Hero Member
  • *****
  • Posts: 2191
Re: Dialogue FileOpen position chose
« Reply #1 on: May 25, 2023, 06:33:08 pm »
How i can chose position to FileOpen dialogue on Windows 10 using Lazarus_2_0_10.
Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Dialogs, StdCtrls, ExtCtrls;
  9.  
  10. type
  11.   TForm1 = class(TForm)
  12.     Button1: TButton;
  13.     OpenDialog1: TOpenDialog;
  14.     Timer1: TTimer;
  15.     procedure Button1Click(Sender: TObject);
  16.     procedure FormCreate(Sender: TObject);
  17.     procedure Timer1Timer(Sender: TObject);
  18.   private
  19.   public
  20.  
  21.   end;
  22.  
  23. var
  24.   Form1: TForm1;
  25.  
  26. implementation
  27.  
  28. {$R *.lfm}
  29.  
  30. uses Windows;
  31.  
  32. procedure TForm1.Button1Click(Sender: TObject);
  33. begin
  34.   Timer1.Enabled := True;
  35.   OpenDialog1.Execute;
  36. end;
  37.  
  38. procedure TForm1.FormCreate(Sender: TObject);
  39. begin
  40.   Timer1.Enabled := False;
  41.   Timer1.Interval := 50;
  42. end;
  43.  
  44. procedure TForm1.Timer1Timer(Sender: TObject);
  45. const
  46.   CDialogClass = '#32770';
  47. var
  48.   Wnd: HWND;
  49. begin
  50.   Wnd := FindWindow(CDialogClass, nil);
  51.   if (Wnd <> 0) and IsWindowVisible(Wnd) then
  52.   begin
  53.     Timer1.Enabled := False;
  54.     SetWindowPos(Wnd, 0, 33, 33, 0, 0, SWP_NOSIZE);
  55.   end;
  56. end;
  57.  
  58. end.

marcio2003

  • Jr. Member
  • **
  • Posts: 69
Re: Dialogue FileOpen position chose
« Reply #2 on: May 29, 2023, 12:23:17 pm »
Hi,
Thank you for your tips!
I'll try to use them to solve my problems.
Lazarus 2.0.10 Windows 10 64bits

 

TinyPortal © 2005-2018