Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
LCL
»
[SOLVED] Windows only issue, invicible border
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
AnchorDocking in my app
by
Fred vS
[
Today
at 10:32:31 pm]
Lazarus Release 4.0
by
calebs
[
Today
at 10:02:56 pm]
[Solved] Learn how to (un...
by
Hansvb
[
Today
at 08:44:26 pm]
string argument as array ...
by
jamie
[
Today
at 08:26:49 pm]
Little Red Riding Hood (t...
by
Lulu
[
Today
at 08:04:22 pm]
compilerproc Problem by u...
by
paule32
[
Today
at 07:53:37 pm]
New version of BGRABitmap
by
circular
[
Today
at 07:53:02 pm]
DeleteDirectory doesn't a...
by
Bart
[
Today
at 07:43:20 pm]
LAMW arduino serial comm ...
by
jmpessoa
[
Today
at 07:38:54 pm]
problem with scrollbox
by
rcmz
[
Today
at 06:37:56 pm]
SynEdit
by
Martin_fr
[
Today
at 06:27:48 pm]
MacOS intel : Lazarus-dar...
by
Selzig
[
Today
at 05:58:28 pm]
I can write your README.m...
by
wp
[
Today
at 05:31:52 pm]
Daraja HTTP Framework 3.0...
by
mjustin
[
Today
at 05:16:20 pm]
my programs crash
by
turunk
[
Today
at 02:54:49 pm]
Looking for industrial pa...
by
krolikbest
[
Today
at 01:45:55 pm]
WM_ message List for dest...
by
paule32
[
Today
at 01:43:04 pm]
FPC 3.3.1 release date an...
by
Martin_fr
[
Today
at 01:08:18 pm]
I lost in Code ...
by
cdbc
[
Today
at 01:00:56 pm]
Feature request/suggestio...
by
440bx
[
Today
at 12:35:16 pm]
[solved] how to post a po...
by
Nicole
[
Today
at 12:12:45 pm]
Somebody interested by RT...
by
Dzandaa
[
Today
at 11:35:10 am]
Feature request/suggestio...
by
440bx
[
Today
at 10:50:23 am]
Serial port
by
MarkMLl
[
Today
at 09:21:57 am]
Ring Type Animation (cann...
by
Boleeman
[
Today
at 07:45:50 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: [SOLVED] Windows only issue, invicible border (Read 308 times)
Handoko
Hero Member
Posts: 5427
My goal: build my own game engine using Lazarus
[SOLVED] Windows only issue, invicible border
«
on:
February 28, 2025, 01:56:28 pm »
Today I am writing a small Windows tool on a Windows 11 laptop.
Try this code on your Windows computer:
Code: Pascal
[Select]
[+]
[-]
procedure
TForm1
.
Button1Click
(
Sender
:
TObject
)
;
begin
Left
:
=
0
;
Top
:
=
0
;
end
;
I am a Linux user, I am not sure but I believe this behavior only happens on Windows 8 and above. After running the code above and clicking the button, the form won't move to the exact top left corner we expected. Here is an old discussion related with this issue:
https://forum.lazarus.freepascal.org/index.php/topic,65298.msg497415.html#msg497415
Does anybody know how to make the code above to work correctly on WinXP to Windows 11? Or how to detect the thickness of the invincible border?
«
Last Edit: March 01, 2025, 08:03:13 am by Handoko
»
Logged
BrunoK
Hero Member
Posts: 698
Retired programmer
Re: Windows only issue, invicible border
«
Reply #1 on:
February 28, 2025, 04:02:59 pm »
Try this :
Code: Pascal
[Select]
[+]
[-]
unit
Unit1
;
{$mode objfpc}{$H+}
interface
uses
Classes
,
SysUtils
,
Forms
,
Controls
,
Graphics
,
Dialogs
,
StdCtrls
{$IFDEF WINDOWS}
,
Windows
{$ENDIF WINDOWS}
;
type
{ TForm1 }
TForm1
=
class
(
TForm
)
Button1
:
TButton
;
procedure
Button1Click
(
Sender
:
TObject
)
;
private
FFormXOffset
:
integer
;
public
end
;
var
Form1
:
TForm1
;
implementation
{$R *.lfm}
{ TForm1 }
procedure
TForm1
.
Button1Click
(
Sender
:
TObject
)
;
var
lPoint
:
TPoint
;
begin
{$IFDEF WINDOWS}
lPoint
.
SetLocation
(
0
,
0
)
;
// Init lPoint to TopLeft of form
lPoint
:
=
ClientToScreen
(
lPoint
)
;
// Retrieve screen coord of form
FFormXOffset
:
=
Left
-
lPoint
.
X
;
// Compute offset relative to declared left.
{$ENDIF WINDOWS}
Left
:
=
FFormXOffset
+
{ Desired real left }
0
;
// Apply offset to desired position
Top
:
=
0
;
end
;
end
.
Logged
Handoko
Hero Member
Posts: 5427
My goal: build my own game engine using Lazarus
Re: Windows only issue, invicible border
«
Reply #2 on:
March 01, 2025, 08:01:39 am »
Yes, it work. Thank you very much. The code may look simple but very helpful. I learned something new today.
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
LCL
»
[SOLVED] Windows only issue, invicible border
TinyPortal
© 2005-2018