Re: generic panel focus
- From: piraticman@xxxxxxxxx
- Date: 16 Nov 2006 05:05:49 -0800
woah. thanks, that's so simple... I didn't think that'd change the
panel cod for each specific one, since it has been assigned a name in
the procedure section, but it does. nice :)
thanks for the help... that will come in handy in the future..
breaker19@xxxxxxxxxxxx wrote:
Highlight the first of your panels in the form designer. Press F11 to
get the Object Inspector.
On the Events tab, double-click the OnEnter property.
Write a code snippet similar to this:
--------------------------8<--------------------------------------------------------------
procedure TForm1.Panel1Enter(Sender: TObject);
begin
// do something - for example
Caption := 'Entered control is ' + (Sender as TPanel).Name;
end;
-------------------------8<----------------------------------------------------------------
Now use the object inspector to put this same event code on all of your
panels. When you highlight the second panel you will see this procedure
in the drop-down for the OnEnter event.
You now have this same bit of code being executed when ANY of your
panels is entered. The SENDER parameter will be the panel that is
entered. So when a user enters panel#7, "Sender" will be Panel#7, and
so on.
Notice that to get any of the properties of the entered panel, you need
to cast Sender as a TPanel- like this: (Sender as TPanel).property -
where property can be any of the panel's properties - width, top, tag,
caption, name, etc.
The event is fired whenever a user tabs to a panel, or clicks on a
control on the panel. It is not fired when the user just clicks on the
panel. Note that it will be fired at start-up if the first panel is the
first control.
piraticman@xxxxxxxxx wrote:
Hi. I'm trying to make a generic code for focused panels, so I don't
have to put the same code in numerous panels.
I have about 10 panels and the tabstop is true. What I'm trying to
figure out some code to check the currently focused panel for a
character in the name and do a task accordingly.
It should be something like:
if currently focused panel's name has the first character as A
(focusedpanel.name [1] = A)
then
execute code...
This is basically so I can tab through all pannels and any that start
with an A in the name will execute a certain code.
thanks
.
- Follow-Ups:
- Re: generic panel focus
- From: alanglloyd@xxxxxxx
- Re: generic panel focus
- From: Maarten Wiltink
- Re: generic panel focus
- References:
- generic panel focus
- From: piraticman
- Re: generic panel focus
- From: breaker19
- generic panel focus
- Prev by Date: Re: Components at Design Time - moving and resizing
- Next by Date: ISO
- Previous by thread: Re: generic panel focus
- Next by thread: Re: generic panel focus
- Index(es):
Relevant Pages
|