Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trap Ctrl+I in Rtf Control 1

Status
Not open for further replies.

wgcs

Programmer
Mar 31, 2002
2,056
0
0
EC
I want to provide keyboard shortcuts for Bold and Italics in the RTF control on my VFP9 form.

The OLEClass is Richtext.RichtextCtrl.1 ( described in the "Insert Object" dialog box as "Microsoft Rich Textbox Control, version 6.0" ).

I have been able to react to the control keys by putting this into the olecontrol.KeyDown method:
Code:
*** ActiveX Control Event ***
LPARAMETERS keycode, shift
IF shift=2
  DO CASE
    CASE keycode=66 && Ctrl+B
      THIS.SelBold = NOT THIS.SelBold 
      NODEFAULT
    CASE keycode=73 && Ctrl+I
      THIS.SelItalic = NOT THIS.SelItalic
      NODEFAULT
    CASE keycode=85 && Ctrl+U
      THIS.SelUnderline = NOT THIS.SelUnderline
      NODEFAULT
  ENDCASE
ENDIF

However, when the user presses Ctrl+I, it ALWAYS inserts a Tab character. This is particularly annoying if you select text, then press Ctrl+I, at which point the selected text disappears, a tab appears in its place, and the format is now Italicized.

I've tried putting this into the KeyPress Method:
Code:
*** ActiveX Control Event ***
LPARAMETERS keyascii
IF keyascii=9
  NODEFAULT
ENDIF
... No joy.

I've tried putting this into the KeyUp method:
Code:
*** ActiveX Control Event ***
LPARAMETERS keycode, shift
IF keycode=73 AND shift=2
  NODEFAULT
ENDIF
... still no joy (no surprise there, since you can see that the tab is inserted when Ctrl+I is pressed, and not when it is let go).

What else can I do?
Perhaps there's a windows message that can be sent to the control HWND via SendMessage to turn off this 'feature'? But where do I find the reference to show what messages I can send it?

- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
NODEFAULT won't do you any good in an ActiveX method; it's a VFP thing.

My experience with ActiveX controls is that you change the parameter to get the same effect. So try setting KeyAscii to 0 in the KeyPress method.

Tamar
 
Absolutely Right Tamar!

Thanks!



- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top