p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Pro VB 6 (http://p2p.wrox.com/forumdisplay.php?f=73)
-   -   accelerator keys and the tab control (http://p2p.wrox.com/showthread.php?t=1498)

pgtips July 10th, 2003 09:43 AM

accelerator keys and the tab control
 
I have a problem with providing accelerator keys for buttons on a tab control.

Keeping it simple to save me typing, if I have a tab control with, say, 3 tabs and each tab has an Update button on it, how can I make it so that the user can hit <alt>U and that will fire the click event of the Update button on the tab that has focus. Needless to say each of the buttons has to have the caption [u]U</u>pdate.

Anyone got any neat tricks for this? Would be much appreciated.

owain July 10th, 2003 10:19 AM

You could change the caption of the appropriate button when the tab is selected from "Update" to "&Update", and change all the other button caption's to "Update"

For example, if you have all 3 buttons in a control array cmdUpdate (cmdUpdate(0), cmdUpdate(1) etc.), you could do something like this:

Code:

cmbUpdate(0).Caption = "Update"
cmbUpdate(1).Caption = "Update"
cmbUpdate(2).Caption = "Update"

cmdUpdate(TabSelected).Caption = "&Update"

I hope that helps.

Regards
Owain Williams

owain July 10th, 2003 10:22 AM

You could always put that into a loop if you have more buttons:

Code:

For lngCount = cmdUpdate.LBound To cmdUpdate.UBound
   cmdUpdate(lngCount).Caption = "Update"
Next

cmdUpdate(TabSelected).Caption = "&Update"

There may be more efficient ways of doing this though.

Regards
Owain Williams

marcostraf July 10th, 2003 04:07 PM

Two cents.
In my opinion the Update button should be outside the tab, just like
the OK, Apply and Cancel buttons (in fact I will call it just Apply).
This is one of the GUI guidelines that I follow, but it is personal.

Marco


Quote:

quote:Originally posted by pgtips
 I have a problem with providing accelerator keys for buttons on a tab control.

Keeping it simple to save me typing, if I have a tab control with, say, 3 tabs and each tab has an Update button on it, how can I make it so that the user can hit <alt>U and that will fire the click event of the Update button on the tab that has focus. Needless to say each of the buttons has to have the caption [u]U</u>pdate.

Anyone got any neat tricks for this? Would be much appreciated.


All times are GMT -4. The time now is 02:57 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.