Recent

Author Topic: [Closed] Holding form position on Win10.  (Read 2073 times)

iru

  • Sr. Member
  • ****
  • Posts: 321
[Closed] Holding form position on Win10.
« on: April 17, 2023, 01:28:15 pm »
Environment: Laz 2.2.6, Win 10 update 22H2, Lenovo X260 I5.

Gentlfolk,

I have a single form application where I wish to position the form on the PC screen and inhibit the user from movin8 the form.

I have done this using Form1.Position poDeskTopCentre (Set in ObjectInspector).

This worked correctly until I migrated to 2.2.6 from 2.2.0 !!!!!

Now the form positions correctly but will move if if 'grabbed' if grabbed by the mouse.

Any directions, ideas? Anyone note anything similar???

Ian.
« Last Edit: April 18, 2023, 12:45:28 pm by iru »

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2010
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Holding form position on Win10.
« Reply #1 on: April 17, 2023, 01:52:07 pm »
Win 10
Code: Pascal  [Select][+][-]
  1. uses Windows;
  2.  
  3. procedure TForm1.FormCreate(Sender: TObject);
  4. var
  5.   LMenu: HMenu;
  6. begin
  7.   Self.Position := poScreenCenter; // this I would use instead of poDesktopCenter
  8.   // Form can not be dragged anymore:
  9.   LMenu := GetSystemMenu(Handle, False);
  10.   DeleteMenu(LMenu, SC_MOVE, MF_BYCOMMAND);
  11. end;
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

iru

  • Sr. Member
  • ****
  • Posts: 321
Re: Holding form position on Win10.
« Reply #2 on: April 18, 2023, 01:12:20 am »
Thank you KodeZwerg your solution solved my problem.

Regards, Ian.

furious programming

  • Hero Member
  • *****
  • Posts: 853
Re: [Closed] Holding form position on Win10.
« Reply #3 on: June 08, 2023, 12:33:30 am »
Code: Pascal  [Select][+][-]
  1. Self.Position := poScreenCenter; // this I would use instead of poDesktopCenter

Everyone should always use poScreenCenter, because in the case of a desktop extended over several screens, poScreenCenter will allow to display a window centered on the main screen. Whereas poDesktopCenter will calculate the center of the desktop and display the window there — I use two screens myself (one next to the other), so the poDesktopCenter style window appears half on the laptop screen and half on the monitor screen.
« Last Edit: June 08, 2023, 12:36:43 am by furious programming »
Lazarus 3.2 with FPC 3.2.2, Windows 10 — all 64-bit

Working solo on an acrade, action/adventure game in retro style (pixelart), programming the engine and shell from scratch, using Free Pascal and SDL. Release planned in 2026.

Bart

  • Hero Member
  • *****
  • Posts: 5275
    • Bart en Mariska's Webstek
Re: [Closed] Holding form position on Win10.
« Reply #4 on: June 08, 2023, 09:45:09 am »
This worked correctly until I migrated to 2.2.6 from 2.2.0 !!!!!

Now the form positions correctly but will move if if 'grabbed' if grabbed by the mouse.
This has always been the case, and is also the case in Delphi.

Bart

 

TinyPortal © 2005-2018