469,167 Members | 1,979 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,167 developers. It's quick & easy.

Set control to the first option in menu bar

274 100+
Hi All
I have a menu bar in vb6 project. I want to set default control to the first option.
If the menu bar has following (File Edit Purchase Report...) I want to set default control on first option of File. So that user may press Alt button to do that.
Can someone help?
Oct 22 '07 #1
11 1189
debasisdas
8,127 Expert 4TB
What do you mean by set default control on first option

What exactly you are trying to do ?

Please pas on few more details .
Oct 22 '07 #2
creative1
274 100+
Well I have a traditional menu with following options (Purchase, Reports, Maintenance.... ) with pullup menus. Like this

Purchase Reports
CashQ Account Statement
Account Balance Sheet

I want to do something like this: when I open software and hit an Enter Key from the keyboard, it start CashQ which is first option in menu.

If user don't want to do Cash-Q he can use arrow keys to scroll between menu options. How I can do this?
I hope now you understand this.
Oct 22 '07 #3
debasisdas
8,127 Expert 4TB
try to call the click event of the first item of the file menu in the keydown event of the form.
Oct 22 '07 #4
Killer42
8,435 Expert 8TB
try to call the click event of the first item of the file menu in the keydown event of the form.
Or perhaps you could use SendKeys to send Alt, then down arrow.
Oct 22 '07 #5
Killer42
8,435 Expert 8TB
try to call the click event of the first item of the file menu in the keydown event of the form.
I don't think that will do the trick. I think the OP just wants to highlight the option, not activate it.
Oct 22 '07 #6
creative1
274 100+
I just want to highlight the first option (or you can say I need to send ALT only)
In fact old system was DOS-based and my supervisor wants me to give it the same look and feel as old.
Please help me with code too... All that is happening on MDI form.
Thanks,
Farhana.
Oct 22 '07 #7
Killer42
8,435 Expert 8TB
I just want to highlight the first option ...
Have you tried any of our suggestions?
Oct 22 '07 #8
creative1
274 100+
As I told you I want to this on an MDIForm so I can't work on KeyDown event. I used a picture box on it and then setcontrol to its KeyDown event. I achieved one of the thing by hitting Enter Key on keydown event of picturebox. Now I want to pass ALT if anykey other than Enter is pressed.
I am trying this.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Picture1_KeyDown(KeyCode As Integer, Shift As Integer)
  2. If KeyAscii = 13 Then
  3.   Call mnuPurchasefrmQuickCash_Click
  4. ElseIf KeyCode = vbKeyP Then
  5.     If Shift And vbAltMask Then
  6.       MsgBox "Alt-S was pressed!"
  7.     End If
  8. End If
  9. End Sub
Oct 22 '07 #9
Killer42
8,435 Expert 8TB
In case you're interested, you can check for KeyCode = 18 to detect ALT pressed, though this is probably not what you want. Just use an Else to detect anything other than Enter.

Also, what's the problem with sending your ALT? Have you tried SendKeys?

By the way, the message you're displaying is misleading. It's activated by Alt-P and says Alt-S was pressed. :-)
Oct 23 '07 #10
creative1
274 100+
I have been using following code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Picture1_KeyDown(KeyCode As Integer, Shift As Integer)
  2. If KeyCode = 13 Then
  3.     Call mnuPurchasefrmQuickCash_Click
  4. Else
  5.    SendKeys ("%{DOWN}")
  6. End If
  7. End Sub
It activates the menu but call in infinite. The control keeps on moving through the menu.......any idea?
If I use only sendkeys(% ) it does nothing simply no effect.
Oct 23 '07 #11
Killer42
8,435 Expert 8TB
Well since you're sending a key (effectively telling Windows that the user pressed it) then I suppose it activates the KeyDown event. Just set a flag and don't do anything until control comes back. Or do nothing if the time is too short since the event was last activated. Use your imagination.

Also, you don't want to send the Alt-Down combination. You want to send Alt first, then Down. It's not the same. Check the SendKeys documentation, I think there's a way to send Alt.
Oct 23 '07 #12

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Yves PEYSSON | last post: by
reply views Thread by john_mcmahon | last post: by
1 post views Thread by veteranwebdesign | last post: by
3 posts views Thread by =?Utf-8?B?VG9tIFc=?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.