Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
LCL
»
[SOLVED] TPanels Top and Bottom
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
WIKI Timeout issues
Please read here if you have trouble connecting to the wiki
Recent
IBX 2.7.2.1650 Bug?
by
incendio
[
Today
at 02:09:59 am]
Where to download IBX pre...
by
incendio
[
Today
at 01:37:39 am]
Strict Aliasing Rule
by
nixbody
[
Today
at 01:30:18 am]
Lazarus 4, What's wrong w...
by
incendio
[
Today
at 12:48:54 am]
Component to manage short...
by
EganSolo
[
Today
at 12:36:36 am]
Replace controls dynamica...
by
Aruna
[June 18, 2025, 11:58:42 pm]
[SOLVED] Which RTL Unit d...
by
tfurnivall
[June 18, 2025, 10:25:01 pm]
CEF component - the first...
by
wp
[June 18, 2025, 08:21:11 pm]
slim installation by remo...
by
wp
[June 18, 2025, 08:19:09 pm]
Crash on changing a strin...
by
Martin_fr
[June 18, 2025, 08:11:34 pm]
How to stop macro executi...
by
Martin_fr
[June 18, 2025, 08:06:44 pm]
Layout problem by nested ...
by
etrusco
[June 18, 2025, 07:55:44 pm]
Build failure
by
user5
[June 18, 2025, 07:42:34 pm]
Loading an image from an ...
by
Fred vS
[June 18, 2025, 06:29:01 pm]
IDE Lazarus 4.0 on Window...
by
Martin_fr
[June 18, 2025, 03:47:30 pm]
Lazarus 4.0 RC3
by
paxnet_be
[June 18, 2025, 02:34:23 pm]
Firebird 5 remote login v...
by
LacaK
[June 18, 2025, 02:07:34 pm]
Compile errors in MacBook...
by
Thaddy
[June 18, 2025, 11:46:06 am]
LAMW - UTF-8 character in...
by
Alcatiz
[June 18, 2025, 11:36:29 am]
How to run an external pr...
by
vsajip
[June 18, 2025, 08:50:34 am]
lazbuild command line swi...
by
n7800
[June 18, 2025, 04:21:35 am]
dBGRidController and Erro...
by
essence-ciel
[June 18, 2025, 01:15:11 am]
"LCLVersion" in *.lfm fil...
by
zeljko
[June 17, 2025, 11:05:36 pm]
FPC for high-performance ...
by
Thaddy
[June 17, 2025, 09:42:33 pm]
x86_64-win64 annoys me
by
Nicole
[June 17, 2025, 08:28:16 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: [SOLVED] TPanels Top and Bottom (Read 1111 times)
Pe3s
Hero Member
Posts: 596
[SOLVED] TPanels Top and Bottom
«
on:
September 01, 2022, 08:25:48 pm »
Hello, I need to add a panel on the top, but then two panels are shown at once, not each panel separately, how can I solve it?
Code: Pascal
[Select]
[+]
[-]
uses
LCLIntf
;
const
ControlPanelHeight
=
40
;
TopPanelHeight
=
32
;
procedure
TForm1
.
FormCreate
(
Sender
:
TObject
)
;
begin
pnControl
.
Height
:
=
0
;
TopPanelHeight
=
0
;
end
;
procedure
TForm1
.
FormMouseMove
(
Sender
:
TObject
;
Shift
:
TShiftState
;
X
,
Y
:
Integer
)
;
var
P
:
TPoint
;
R
:
TRect
;
begin
R
:
=
TRect
.
Create
(
0
,
Self
.
Height
-
ControlPanelHeight
,
Self
.
Width
,
Self
.
Height
)
;
P
.
X
:
=
X
;
P
.
Y
:
=
Y
;
if
PtInRect
(
R
,
P
)
then
pnControl
.
Height
:
=
ControlPanelHeight
else
pnControl
.
Height
:
=
0
;
end
;
procedure
TForm1
.
pnControlMouseLeave
(
Sender
:
TObject
)
;
begin
pnControl
.
Height
:
=
0
;
end
;
«
Last Edit: September 02, 2022, 07:01:44 pm by Pe3s
»
Logged
paweld
Hero Member
Posts: 1419
Re: TPanels Top and Bottom
«
Reply #1 on:
September 01, 2022, 09:10:08 pm »
I don't know if I understood correctly - you mean hiding
Panel1
when
pnControl
is visible?
Code: Pascal
[Select]
[+]
[-]
procedure
TForm1
.
FormCreate
(
Sender
:
TObject
)
;
begin
pnControl
.
Visible
:
=
False
;
Panel1
.
Visible
:
=
True
;
end
;
procedure
TForm1
.
FormMouseMove
(
Sender
:
TObject
;
Shift
:
TShiftState
;
X
,
Y
:
Integer
)
;
var
R
:
TRect
;
begin
R
:
=
Rect
(
0
,
Height
-
pnControl
.
Height
,
Width
,
Height
)
;
pnControl
.
Visible
:
=
R
.
Contains
(
Point
(
X
,
Y
)
)
;
Panel1
.
Visible
:
=
not
pnControl
.
Visible
;
end
;
Logged
Best regards / Pozdrawiam
paweld
howardpc
Hero Member
Posts: 4144
Re: TPanels Top and Bottom
«
Reply #2 on:
September 01, 2022, 09:11:28 pm »
If I have understood the behaviour you are after I think the attached project shows one way to achieve it.
Logged
Pe3s
Hero Member
Posts: 596
Re: TPanels Top and Bottom
«
Reply #3 on:
September 01, 2022, 09:47:03 pm »
@ paweld it's about hiding two panels and showing each of them after hovering over the mouse and hiding them after taking the mouse
Logged
paweld
Hero Member
Posts: 1419
Re: TPanels Top and Bottom
«
Reply #4 on:
September 01, 2022, 10:19:48 pm »
The solution was provided by @howardpc. But you can also do it like this
Code: Pascal
[Select]
[+]
[-]
procedure
TForm1
.
FormCreate
(
Sender
:
TObject
)
;
begin
panel1
.
Visible
:
=
False
;
pnControl
.
Visible
:
=
False
;
end
;
procedure
TForm1
.
FormMouseMove
(
Sender
:
TObject
;
Shift
:
TShiftState
;
X
,
Y
:
Integer
)
;
begin
panel1
.
Visible
:
=
panel1
.
BoundsRect
.
Contains
(
Point
(
X
,
Y
)
)
;
pnControl
.
Visible
:
=
pnControl
.
BoundsRect
.
Contains
(
Point
(
X
,
Y
)
)
;
end
;
Logged
Best regards / Pozdrawiam
paweld
KodeZwerg
Hero Member
Posts: 2269
Fifty shades of code.
Re: TPanels Top and Bottom
«
Reply #5 on:
September 01, 2022, 10:49:28 pm »
Idk "the solution" but i would suggest to use Mouse Enter and Leave event.
Logged
«
Last Edit:
Tomorrow
at 31:76:97 xm by
KodeZwerg
»
paweld
Hero Member
Posts: 1419
Re: TPanels Top and Bottom
«
Reply #6 on:
September 02, 2022, 06:55:12 am »
if the panel is not visible then
OnMouseEenter
will not work
Logged
Best regards / Pozdrawiam
paweld
Pe3s
Hero Member
Posts: 596
Re: TPanels Top and Bottom
«
Reply #7 on:
September 02, 2022, 06:40:54 pm »
Hi @paweld what do I have to correct in the code so that there is no error
Code: Pascal
[Select]
[+]
[-]
procedure
TForm1
.
Image32MouseMove
(
Sender
:
TObject
;
Shift
:
TShiftState
;
X
,
Y
:
Integer
;
Layer
:
TCustomLayer
)
;
begin
Toolbar
.
Visible
:
=
Toolbar
.
BoundsRect
.
Contains
(
Point
(
X
,
Y
)
)
;
end
;
Code: Pascal
[Select]
[+]
[-]
unit1
.
pas
(
68
,
57
)
Fatal
:
Syntax error
,
"
)
" expected but "
,
" found
Logged
Pe3s
Hero Member
Posts: 596
Re: TPanels Top and Bottom
«
Reply #8 on:
September 02, 2022, 07:01:23 pm »
Thank you for your help, great beer, gentlemen
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
LCL
»
[SOLVED] TPanels Top and Bottom
TinyPortal
© 2005-2018