|
-
Apr 18th, 2007, 07:30 AM
#1
Thread Starter
Lively Member
[RESOLVED] How do I implement use of Key + Click?
Hey guys! In my program a user clicks on this command button to access the next form. However, I want to implement it such a way that when a user holds down the ctrl key AND clicks on the command button, it will bring them to another "secret" form. How do I do this? Thanks for the help!
-
Apr 18th, 2007, 09:17 AM
#2
Re: How do I implement use of Key + Click?
(If you don't want to use API) Use the MouseUp event instead of Click event.
vb Code:
Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim CtrlDown As Integer
CtrlDown = Shift And 7
If CtrlDown = vbCtrlMask Then 'control key pressed
MsgBox "Show HIDDEN form"
Else
MsgBox "Show regular form"
End If
End Sub
Reference:
http://msdn2.microsoft.com/en-us/lib...30(VS.60).aspx
http://msdn2.microsoft.com/en-us/lib...14(VS.60).aspx
-
Apr 18th, 2007, 10:17 AM
#3
Thread Starter
Lively Member
Re: How do I implement use of Key + Click?
What does this part mean?
-
Apr 18th, 2007, 12:55 PM
#4
Thread Starter
Lively Member
Re: How do I implement use of Key + Click?
Anyone can teach me about this?
-
Apr 18th, 2007, 12:59 PM
#5
Lively Member
Re: How do I implement use of Key + Click?
 Originally Posted by zabimaru
What does this part mean?
Read this:
http://msdn2.microsoft.com/en-us/lib...234(VS.60).asp
Last edited by lewmur; Apr 18th, 2007 at 01:02 PM.
-
Apr 18th, 2007, 01:56 PM
#6
Re: How do I implement use of Key + Click?
And here is used as a bitwise comparison operator. (See bottom part of this page.)
These pages may give you more information:
http://www.bitwisemag.com/2/Bit-Shif...Visual-Basic-6
http://groups.google.com/group/comp....ab2629525741bf
(IMO, the best place to learn about bitwise operation is from the related chapter in a C/C++ book or from the logic-gates chapter from your college digital electronics book and a little bit of binary mathematics.)
-
Apr 18th, 2007, 01:58 PM
#7
Re: How do I implement use of Key + Click?
Actually
Code:
Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Shift And 7 = vbCtrlMask Then 'only look at the Shift, Control and Alt keys
'vbShift Mask and vbAlt Mask also work
'and the bits can be ORed
'control key alone was pressed
MsgBox "Show HIDDEN form"
Else
'control key alone wasn't pressed
MsgBox "Show regular form"
End If
End Sub
will also work.
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 19th, 2007, 07:18 AM
#8
Thread Starter
Lively Member
Re: How do I implement use of Key + Click?
Herm.. So if instead I want a hidden form to pop up, upon pressing and holding down Ctrl + Shift + A, does the following code work?
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyCtrl And KeyCode = vbKeyShift And KeyCode = vbKeyA Then
frmHidden.Show
End If
End Sub
And set KeyPreview to True?
-
Apr 19th, 2007, 07:24 AM
#9
Re: How do I implement use of Key + Click?
Try
vb Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If (Shift And vbCtrlMask) = vbCtrlMask And KeyCode = vbKeyA Then
frmHidden.Show
End If
End Sub
-
Apr 19th, 2007, 07:32 AM
#10
Thread Starter
Lively Member
Re: How do I implement use of Key + Click?
Your code worked Hack, mine broke haha. Thanks a lot for the help! =)
-
Apr 19th, 2007, 11:15 AM
#11
Re: [RESOLVED] How do I implement use of Key + Click?
That'll work if they hold down Ctrl + A or Shift + Ctrl + A. You want
Code:
If (Shift And (vbCtrlMask Or vbShiftMask) ) = (vbCtrlMask Or vbShiftMask)
And KeyCode = vbKeyA Then
Last edited by Hack; Apr 19th, 2007 at 01:25 PM.
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
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
|