GPWiki.org
GPWiki.org
It is currently Wed May 22, 2013 3:11 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Wed Feb 18, 2009 9:58 pm 
Hello
I want to zoom in and out of an image with control + and -, I want to use the upper function of the = key,not the big plus key of the numberpad. I cannot find the vbkeycode nor the keydown for these keys!
Visual Basic 6
Any help would be fantastic

Regards
David


Top
  
 
 Post subject:
PostPosted: Thu Feb 19, 2009 4:58 pm 
Mumbo Jumbo
User avatar

Joined: Fri Aug 20, 2004 1:15 pm
Posts: 804
Location: Michigan, USA
just use the keycode of the = key (187)
- (minus) key is 189

Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 187 Then
        Form1.Caption = "Plus Key Down"
    ElseIf KeyCode = 189 Then
        Form1.Caption = "Minus Key Down"
    Else
        Form1.Caption = "Some other key Down"
    End If
End Sub


or

Code:
Private Sub Form_KeyPress(KeyAscii As Integer)
    If KeyAscii = Asc("=") Then
        Form1.Caption = "Plus Key Down"
    ElseIf KeyAscii = Asc("-") Then
        Form1.Caption = "Minus Key down"
    Else
        Form1.Caption = "Some other key Down"
    End If
End Sub

_________________
The path to hell is paved with clever code.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 19, 2009 5:06 pm 
Dexterous Droid
User avatar

Joined: Fri Dec 24, 2004 8:13 pm
Posts: 3769
Location: Michigan, 'US' of 'A'. Below Canada.
Also you can MessageBox the KeyCode

_________________
/\/////////// \\\\\\\\\\\/\S
/\/////////\\ //\\\\\\\\\/\I - Assault Wars
/\///////\\//|\\//\\\\\\\/\R - - Work in Progress
/\/////\\////|\\\\//\\\\\/\I
/\///\\/////\|/\\\\\//\\\/\S


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 24, 2009 6:19 am 
Cubic Contributor

Joined: Tue Jul 08, 2008 9:03 am
Posts: 79
to check the state of two keys simultaneously using just the keydown / keyup event (not any other API's), you would need to create two boolean variables- one for each of the keys you're testing

dim ctrl as boolean
dim plus as boolean

on keydown:

if keycode = vbKeyControl (or whatever it is) then
ctrl = true
end if

if keycode = vbkeyplus (or w/e) then
plus = true
end if

do the opposite on key up. Then you can check if ctrl = true and plus = true. Unless you feel like using Windows API or DirectInput, thats the way to go.

_________________
A pawn can eventually become a queen...


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group