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
Getting name / line of ca...
by
Prime
[
Today
at 04:23:19 pm]
Qt does not position form...
by
Alexx2000
[
Today
at 03:52:43 pm]
Application.QueueAsyncCal...
by
Thaddy
[
Today
at 03:17:23 pm]
FPC Unleashed (inline var...
by
Fibonacci
[
Today
at 02:03:21 pm]
Windows API Hooking/DLL I...
by
Thaddy
[
Today
at 01:08:56 pm]
How do 'with' statements ...
by
Thaddy
[
Today
at 01:00:07 pm]
TComboBoxEx & TCheckCombo...
by
Paolo
[
Today
at 11:28:00 am]
DataPort or Synpase stat...
by
serbod
[
Today
at 09:30:51 am]
SynEdit auto End of line ...
by
Martin_fr
[
Today
at 09:08:36 am]
Show Case: WritingTool
by
ginoo
[
Today
at 08:47:02 am]
How to view the TODO list...
by
Thaddy
[
Today
at 07:16:27 am]
Scripts to generate ofici...
by
dbannon
[
Today
at 02:25:56 am]
P.I.S.S. a PlugIn-framewo...
by
cdbc
[
Today
at 01:20:44 am]
International Pascal Cong...
by
Mike.Cornflake
[May 09, 2026, 06:45:37 pm]
SpreadSheet Add Chart Lin...
by
eldonfsr
[May 09, 2026, 06:19:33 pm]
How to access inherited m...
by
Thaddy
[May 09, 2026, 04:12:38 pm]
Anubis activated
by
LemonParty
[May 09, 2026, 03:46:01 pm]
RunFormula: math expressi...
by
LeP
[May 09, 2026, 03:39:53 pm]
Setting canvas offset wit...
by
jamie
[May 09, 2026, 03:14:04 pm]
Limiting Search in TSelec...
by
jamie
[May 09, 2026, 03:09:21 pm]
using make with a differe...
by
Thausand
[May 09, 2026, 02:41:39 pm]
FreeBSD 13/14: RTL dirent...
by
Fred vS
[May 09, 2026, 02:33:11 pm]
Problems with form.AutoSc...
by
OH1KH
[May 09, 2026, 12:07:44 pm]
AVRPascal – free code edi...
by
ackarwow
[May 09, 2026, 09:23:14 am]
Can /my/ AI help me with ...
by
valdir.marcos
[May 09, 2026, 08:34:18 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: [SOLVED] TPanels Top and Bottom (Read 1313 times)
Pe3s
Hero Member
Posts: 641
[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: 1607
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: 641
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: 1607
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: 1607
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: 641
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: 641
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