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
Forum Rules
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Printer Info
by
LeP
[
Today
at 07:57:09 pm]
Lazarus Main and Gnome/Wa...
by
Jonax
[
Today
at 07:49:47 pm]
WEBP, no DLLs
by
Tomxe
[
Today
at 07:40:17 pm]
MacOS post compilation sc...
by
marcou
[
Today
at 07:30:07 pm]
made hooking newinstance ...
by
Thaddy
[
Today
at 07:24:08 pm]
water filling simulation
by
Dzandaa
[
Today
at 06:53:35 pm]
[New Component] ExtTabCtr...
by
wp
[
Today
at 06:48:14 pm]
XLibre, finally and fortu...
by
Thaddy
[
Today
at 06:37:12 pm]
Pdf Viewer in Pascal
by
Tomxe
[
Today
at 05:00:32 pm]
Sizes and SizeInt
by
LemonParty
[
Today
at 03:05:53 pm]
How can 'Canvas does not ...
by
J-G
[
Today
at 03:05:01 pm]
AArch64. Fast method to c...
by
Thaddy
[
Today
at 01:58:45 pm]
I found an actual use for...
by
Thaddy
[
Today
at 01:07:16 pm]
Strange Behaviour at Runt...
by
andrew Bubble
[
Today
at 12:41:49 pm]
Can /my/ AI help me with ...
by
microxa
[
Today
at 12:12:06 pm]
Knigo
by
CM630
[
Today
at 12:05:31 pm]
P.I.S.S. a PlugIn-framewo...
by
cdbc
[
Today
at 11:27:35 am]
[solved] rotate image pro...
by
speter
[
Today
at 10:03:42 am]
TstringGrid read cell col...
by
Josh
[June 08, 2026, 11:05:23 pm]
Pascal for AI Agent CLI T...
by
schuler
[June 08, 2026, 10:35:41 pm]
is there a Base 26 / Radi...
by
Josh
[June 08, 2026, 08:54:36 pm]
FPC Unleashed (inline var...
by
Fibonacci
[June 08, 2026, 08:49:31 pm]
Notetask 1.1.4 - Free cro...
by
AlexanderT
[June 08, 2026, 04:55:38 pm]
Pixie: A lightweight HTML...
by
Tomxe
[June 08, 2026, 01:48:30 pm]
EasyLazFreeType Bug?
by
Tommi
[June 08, 2026, 10:57:47 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: [SOLVED] TPanels Top and Bottom (Read 1314 times)
Pe3s
Hero Member
Posts: 647
[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: 1639
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: 647
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: 1639
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: 1639
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: 647
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: 647
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