Solved

How can I assign a tab value to a label or panel?

Posted on 2000-04-30
5
268 Views
Last Modified: 2010-04-04
I want to provide access to labelclicks or panelclicks via the keyboard, using cursor keys or tab to cycle through. Windows lets you do it with the tab value on buttons which is fine, but can I do it with labels and panels which see to have no tab value available?
0
Comment
Question by:chriswood
5 Comments
 
LVL 7

Expert Comment

by:Motaz
ID: 2763534
Labels and Panels is not a Window controls, so that it cann't accept FOCUS!

Motaz
0
 
LVL 9

Expert Comment

by:ITugay
ID: 2763637
Hi chriswood.

You can do it with TPanels but not with TLabel. Look at this topic:
-----
Use the TabStop to allow or disallow access to the control using the Tab key. If TabStop is True, the control is in the tab order. If TabStop is False, the control is not in the tab order and the user can't press the Tab key to move to the control.
-----

The TabStop property appears in TWinControl hierarchy level and TLabel have not this property.

To be sure it work with panels try this sample:

1. new app
2. drop four panels on your form
3. drop TEdit
4. drop TTimer
5. set property TPanel1..4.TabStop = true

6. write TTimerTimer event like this:

procedure TForm1.Timer1Timer(Sender: TObject);
begin
   if ActiveControl is TPanel
   then Edit1.Text:=TPanel(ActiveControl).Name;
end;

7. run your app
8. press [tab] or [arrow] keys to see ActiveControl name.

------
Igor.

0
 
LVL 3

Expert Comment

by:sburck
ID: 2763788
When I try to do panel selection, I usually keep all panels without a border until they are selected.  In a single, combined OnEnter and OnExit method for all the selectable panels I have this code:

procedure TForm1.PanelEnter(Sender: TObject);
begin
     (Sender as TPanel).BorderStyle = bsSingle;
end;

procedure TForm1.PanelExit(Sender: TObject);
begin
     (Sender as TPanel).BorderStyle = bsNone;
end;
 
Put a bunch of panels on your form, give all of their OnEnter's the PanelEnter method, all of their OnExit's the PanelExit method, and run it.  Tabbing between them is very clear.

You can do other things like changing colors, but this is simple and effective.
0
 

Author Comment

by:chriswood
ID: 2763824
Yep, thanks guys, I missed panel had a tab value... (duh)

but does anyone have a method for using tab or cursor keys on non-tab objects such as labels...?  That's what I really want...

but thanks for the tip about the border, (sburck) I like that.
 
0
 
LVL 3

Accepted Solution

by:
sburck earned 100 total points
ID: 2763839
Here, Motaz is right - any control which isn't a Window control can't get a focus.  Here, too, though, you can fake it using a panel.  Shrink the panel to the size of the label, make it 'invisible' (bevelinner & bevelouter to bvnone), and change the fontstyle of the caption on the onenter and onexit.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to use Hashing sha1 in Delphi 2010 4 199
Strange behavior when a form is closed 6 51
find a node in VST 2 63
Dynamically Created Query 3 50
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now