Microsoft KB Archive/125733

{| = How to Create a Hot Key for a Push Button with a Bitmap =
 * width="100%"|

ID: Q125733

2.50 2.50a 2.50b 2.60 2.60a WINDOWS kbtool

The information in this article applies to:


 * Microsoft FoxPro for Windows, versions 2.5, 2.5a, 2.5b, 2.6, 2.6a

SUMMARY
The FoxPro Screen Builder usually allows the association of a hot key combination with a push button. A hot key allows a key stroke or a combination of key strokes to activate a push button without physically placing the cursor on the object. Unfortunately, a picture push button cannot possess a hot key combination. However, the ON KEY LABEL command allows specific key strokes to emulate a hot key combination. This article shows by example how to do it.

MORE INFORMATION
The following steps illustrate how to remap the CTRL+F1 keys to activate the Valid code snippet of a picture push button. The FOXPRO.BMP file is located in the FoxPro for Windows main directory.

1. Create a screen with a picture push button by using the FOXPRO.BMP file.

2. In the Setup code of the screen, type the following code:

ON KEY LABEL CTRL+F1 DO Hot_key 3. Save the Setup code snippet and open the Valid code snippet of the push button. Make sure the code snippet is a procedure and type:

DO Hot_key 4. Save the Valid code snippet and close the push button builder dialog box. 5. Open the Screen Layout dialog, choose the Code button, and click the Cleanup and Procedures button. In this code snippet, type the following code:

ON KEY LABEL CTRL+F1

PROCEDURE Hot_key WAIT WINDOW "Now the push button has a Hot Key!" RETURN 6. Add another push button, and type "Quit" in the "Push Button  Prompts" dialog. Also, check the "Terminate READ on Selection" check box. Finally, save the push button, and generate the screen. The ON KEY LABEL command in the Setup code snippet remaps the CTRL+F1 keys to activate the procedure in the Valid code snippet of the picture push button. This functionality gives the illusion of a hot key combination for the push button. The ON KEY LABEL CTRL+F1 statement in the Cleanup and Procedures code snippet resets the key combination back to its default value when exiting the screen.

Other than using the KEYBOARD "{TAB}" command, there is no way to set the focus to a button after pressing CTRL+F1. Using the SHOW GET command or the _CUROBJ will not set the focus to the push button.

Additional reference words: FoxWin 2.50 2.50a 2.50b 2.60 2.60a KBCategory: kbtool KBSubcategory: FxtoolSbuilder

Keywords         : FxtoolSbuilder Version          : 2.50 2.50a 2.50b 2.60 2.60a Platform         : WINDOWS
 * }