Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Not Necessary but would be nice
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00139787
Message ID:
00140033
Views:
28
Bob, this can be done by adding the ALT in the keypress event. Below is a sample numberpad class using this method which I'll also e-mail to you.
**************************************************
*-- Class:        numberpad (c:\temp\keyclickbuttons.vcx)
*-- ParentClass:  container
*-- BaseClass:    container
*
DEFINE CLASS numberpad AS container

	Width = 72
	Height = 131
	BorderWidth = 0
	Name = "numberpad"
	clicked = .F.

	ADD OBJECT text1 AS textbox WITH ;
		Height = 23, ;
		Left = 0, ;
		Top = 108, ;
		Width = 72, ;
		Name = "Text1"

	ADD OBJECT cmdkeyclickbutton1 AS cmdkeyclickbutton WITH ;
		Top = 0, ;
		Left = 0, ;
		Name = "Cmdkeyclickbutton1"

	ADD OBJECT cmdkeyclickbutton2 AS cmdkeyclickbutton WITH ;
		Top = 0, ;
		Left = 24, ;
		Name = "Cmdkeyclickbutton2"

	PROCEDURE text1.KeyPress
		LPARAMETERS nKeyCode, nShiftAltCtrl

		&& Trap keys 0-9 if this keystroke didn't come from a mouseclick
		*wait window str(nkeycode)

		if  between(nKeyCode, 48, 57) and nShiftAltCtrl = 0 and ;
		  ! this.parent.Clicked
			*Stuff the keyboard with ALT+KEY combination
			c = '{ALT+' + chr(nKeyCode)+'}'
			keyboard(c)
			*Eliminate the initial key that was press from displaying
			nodefault
			this.parent.clicked = .t.
		else
			this.parent.clicked = .f.
		endif
	ENDPROC

ENDDEFINE
*
*-- EndDefine: numberpad
**************************************************

**************************************************
*-- Class:        cmdkeyclickbutton (c:\temp\keyclickbuttons.vcx)
*-- ParentClass:  commandbutton
*-- BaseClass:    commandbutton
*
DEFINE CLASS cmdkeyclickbutton AS commandbutton

	Height = 26
	Width = 24
	Caption = ""
	TabStop = .F.
	Name = "cmdkeyclickbutton"

	PROCEDURE Click
		* Stuff the keyboard with the last character of the 
		* caption of this button

		keyboard(right(this.caption, 1))
		this.parent.text1.setfocus()
	ENDPROC

	PROCEDURE MouseUp
		LPARAMETERS nButton, nShift, nXCoord, nYCoord

		* Set the "MouseClick" flag to prevent an endless loop
		* between the text.keypress, and button.click

		oObject = sys(1270)
		if oObject.name = this.name
			this.parent.Clicked = .t.
		else
			this.parent.Clicked = .f.
		endif
	ENDPROC

	PROCEDURE Init
		* Set caption based on the last character of 
		* this object's name

		this.caption = '\<' + right(this.name, 1)
	ENDPROC

ENDDEFINE
*
*-- EndDefine: cmdkeyclickbutton
**************************************************
>Hi All,
>
>I was looking for a way to [Press Down] a button on a form
>upon interception of the Keypress event. Lets say in like
>a calculator type form, where the user would either Hit a button
>with the mouse (Thus showing the button being pressed)
>or intercepting the #'s from the Keypad and showing the #'s being
>pressed on the form.
>
>I have tried firing out to some of the different events and
>styles (3d plain, etc..) and was wondering if anyone has
>any suggestions?
>
>Thanx,
>Bob :-)
kenweber
GCom2 Solutions
Microsoft Certified Professional

Previous
Next
Reply
Map
View

Click here to load this message in the networking platform