|
-
Apr 20th, 2007, 04:31 AM
#1
Thread Starter
Member
[RESOLVED] Shortcut key to a form's button while a MdiForm is existed
Hi~ I am very fresh in VB, this forum really help me a lot.
Actaully what I want to do is assign a shortcut key to a button (Alt+a) at form A. But, the problem is, system take priority of run MdiForm's menu first once i press "Alt" key on the keyboard.
So, I think for another way to overcome this problem that is call the Command1_Click function by MdiForm's menu.
The code I write is for the mdiForm menu is:
vb Code:
Private Sub menuAdd_Click()
Call formA.Command1_Click
End Sub
Sure, it doesn't run bcoz the data member .Command1_Click is not found.
Anyone have an idea?
Last edited by Ropyon; Apr 20th, 2007 at 05:47 AM.
-
Apr 20th, 2007, 04:38 AM
#2
Re: Shortcut key to a form's button while a MdiForm is existed
You can directly call like this
vb Code:
Private Sub menuAdd_Click()
btnAdd_Click
End Sub
Please mark you thread resolved using the Thread Tools as shown
-
Apr 20th, 2007, 04:43 AM
#3
Thread Starter
Member
Re: Shortcut key to a form's button while a MdiForm is existed
Thanks for your fast respond~
It doesn't work. bcoz the btnAdd_Click function is in Form A, but menuAdd_Click function is in MidForm, is 2 different form~
-
Apr 20th, 2007, 05:03 AM
#4
Re: Shortcut key to a form's button while a MdiForm is existed
You could do onething.Place a Function in a Module.And in the click event call that Function
Last edited by danasegarane; Apr 20th, 2007 at 05:10 AM.
Please mark you thread resolved using the Thread Tools as shown
-
Apr 20th, 2007, 05:44 AM
#5
Thread Starter
Member
Re: Shortcut key to a form's button while a MdiForm is existed
hmm~ i think of this way before, but is it suitable to create a new module just for a single form's local function?
really appreciate your idea~ i will giv a try~ thX
Anyway, now what i most want to know is How to assign a ShortCut to a form's button if a mdiForm is existed? It is the straightest way to solve my problem~
-
Apr 20th, 2007, 06:29 AM
#6
Re: Shortcut key to a form's button while a MdiForm is existed
You can do this like this
1.Trap the key press event
2.In that Suppress that event.and call your click event
Please mark you thread resolved using the Thread Tools as shown
-
Apr 20th, 2007, 10:27 AM
#7
Re: Shortcut key to a form's button while a MdiForm is existed
 Originally Posted by Ropyon
Hi~ I am very fresh in VB, this forum really help me a lot.
Actaully what I want to do is assign a shortcut key to a button (Alt+a) at form A. But, the problem is, system take priority of run MdiForm's menu first once i press "Alt" key on the keyboard.
Put this code in Form A
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If Shift = vbAltMask And KeyCode = vbKeyA Then
'do what you want here
End If
End Sub
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.
Please Help Us To Save Ana
-
Apr 20th, 2007, 01:24 PM
#8
Re: Shortcut key to a form's button while a MdiForm is existed
If you want to execute what is in the click event of a button on another from do
Code:
Form1.Command1.Value = True
-
Apr 20th, 2007, 01:36 PM
#9
Re: Shortcut key to a form's button while a MdiForm is existed
Or just Form1.Command1_Click
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.
Please Help Us To Save Ana
-
Apr 21st, 2007, 07:20 AM
#10
Thread Starter
Member
Re: Shortcut key to a form's button while a MdiForm is existed
 Originally Posted by Hack
If you want to execute what is in the click event of a button on another from do
vb Code:
Form1.Command1.Value = True
LoL, what a simple code? But it was answered my question about execute another form's function from mdiForm!! thx Mod!!~
-
Apr 21st, 2007, 07:27 AM
#11
Thread Starter
Member
Re: Shortcut key to a form's button while a MdiForm is existed
 Originally Posted by Al42
Put this code in Form A
vb Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If Shift = vbAltMask And KeyCode = vbKeyA Then
'do what you want here
End If
End Sub
Yeah, this is actually what i want find out! Assign a ShortCut key to a Function.
Once i press the "Alt + A" button, the function was executed! But I should replace the Form_KeyDown to Command1_KeyDown first.
Thx alL of you efffort to help me~ appreciated and hope it wilL help other so.
Last edited by Ropyon; Apr 21st, 2007 at 07:37 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|