Forum > Win32/64
[Closed] Holding form position on Win10.
(1/1)
iru:
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.
KodeZwerg:
--- Quote from: iru on April 17, 2023, 01:28:15 pm ---Win 10
--- End quote ---
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses Windows; procedure TForm1.FormCreate(Sender: TObject);var LMenu: HMenu;begin Self.Position := poScreenCenter; // this I would use instead of poDesktopCenter // Form can not be dragged anymore: LMenu := GetSystemMenu(Handle, False); DeleteMenu(LMenu, SC_MOVE, MF_BYCOMMAND);end;
iru:
Thank you KodeZwerg your solution solved my problem.
Regards, Ian.
furious programming:
--- Quote from: KodeZwerg on April 17, 2023, 01:52:07 pm ---
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Self.Position := poScreenCenter; // this I would use instead of poDesktopCenter
--- End quote ---
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.
Bart:
--- Quote from: iru on April 17, 2023, 01:28:15 pm ---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.
--- End quote ---
This has always been the case, and is also the case in Delphi.
Bart
Navigation
[0] Message Index