Button press using key stroke
Button press using key stroke
(OP)
I'm scratching out some code in VB6 and was wondering if anybody ever tried this?
Can or has anyone been able to make a command button LOOK like it has been clicked when a key on the keyboard has been pressed?
Say a command button on a calculator with the caption "1" appears to depress when the number 1 on the keyboard is pressed?
Is this possible or have i wasted half of a sunday afternoon?
Can or has anyone been able to make a command button LOOK like it has been clicked when a key on the keyboard has been pressed?
Say a command button on a calculator with the caption "1" appears to depress when the number 1 on the keyboard is pressed?
Is this possible or have i wasted half of a sunday afternoon?





RE: Button press using key stroke
Then at myForm_KeyPress
check for the keys and activate the button according to the key
It will work also clicking the buttons
RE: Button press using key stroke
I have already done what you suggest and everything works fine. What i was wondering was, is there an easy way to make the button APPEAR to depress when the KEYBOARD is stroked. The rest of the code works fine, i was just trying to raise the visual coolness. If it's a big deal dont worry about it.
RE: Button press using key stroke
Draw a bitmap (using MSPaint for instance) the same size as the button will be. It's size in MSPaint will be in pixels, your button size by default is in Twips, so get your Form TwipsPerPixel figure (usually 15 for SVGA displays) and divide button size by TwipsPerPixel to get size in MSPaint.
Do 2 .bmps, one for buttonup and one for buttondown.
On the form set the Command button Style property to 1 - Graphical, and assign the .bmps to the Picture property and the DownPicture property
That's it!
RE: Button press using key stroke
Obviously you then change the Picture property on the appropriate KeyPress event to simulate the Click Event