Commenting via shortcut keys in VFP

topic: 

The comment/uncomment items on the Format menu do not have shortcut keys but they have access keys assigned. Pressing ALT+om and ALT+on on a keyboard will comment/uncomment selected text respectively.

Rick shows in his blog Commenting via ShortCut Key in Visual FoxPro how to implement MS VS shortcut keys CTRL+K+C and CTRL+K+U to comment/uncomment code using KEYBOARD command. The same can be done with Editor functions from Foxtools.fll. It gives more control over the process, like checking if anything is selected, etc. See George Tasker's Extended Foxtools Help Download #9333 on UT

for more info.

$SAMPLECODE$

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
ON KEY LABEL CTRL+K do VsStyleComment
...

FUNCTION VsStyleComment
LOCAL lnKey, lnWhandle

lnKey = INKEY(.5,"HM")
lnWhandle = _WonTop()

DO CASE
CASE lnKey = 3  && Ctrl-C
	= _EdComment(lnWhandle, 1)
CASE lnKey = 21  && Ctrl-U
	= _EdComment(lnWhandle, -1)
ENDCASE
ENDFUNC

FUNCTION _WonTop
SET LIBRARY TO FoxTools ADDITIVE
RETURN = _WonTop()
ENDFUNC

$SEEALSO$ Copy Command Window Selected Text to Clipboard programmatically, Changing Command Window Font Programmatically, Copy PRG contents to Clipboard

Comments