>LPARAMETERS nKeyCode, nShiftAltCtrl > >LOCAL nInsert, cNewText, nStart >nInsert = THIS.SelStart >IF This.SelLength = 0 > nStart = MAX(nInsert,0) >ELSE > nStart = MAX(nInsert,0) >ENDIF >DO CASE > CASE nKeyCode = -4 && F5 > cNewText = LEFT(THIS.Value, nStart) + allt(userctrl.f5) + substr(THIS.Value, nStart+1) > This.Value = cNewText > This.SelStart = nStart + Len(allt(userctrl.f5)) > NODEFAULT > CASE nKeyCode = -5 && F6 > cNewText = LEFT(THIS.Value, nStart) + allt(userctrl.f6) + substr(THIS.Value, nStart+1) > This.Value = cNewText > This.SelStart = nStart + Len(allt(userctrl.f6)) > NODEFAULT > CASE nKeyCode = -6 && F7 > cNewText = LEFT(THIS.Value, nStart) + allt(userctrl.f7) + substr(THIS.Value, nStart+1) > This.Value = cNewText > This.SelStart = nStart + Len(allt(userctrl.f7)) > NODEFAULT > CASE nKeyCode = 48 .and. nShiftAltCtrl = 2 && Cntl+0 pressed > * do nothing at all > NODEFAULT > OTHERWISE > DODEFAULT() >ENDCASE >>
oForm = CREATEOBJECT([Form1]) oForm.Show(1) DEFINE CLASS form1 AS form DoCreate = .T. Name = "Form1" ADD OBJECT edit1 AS editbox WITH ; Height = 196, ; Left = 26, ; Top = 18, ; Width = 304, ; Name = "Edit1" PROCEDURE edit1.KeyPress LPARAMETERS nKeyCode, nShiftAltCtrl LOCAL nInsert, cNewText, nStart nInsert = THIS.SelStart IF This.SelLength = 0 nStart = MAX(nInsert,0) ELSE nStart = MAX(nInsert,0) ENDIF DO CASE CASE nKeyCode = -4 && F5 cNewText = LEFT(THIS.Value, nStart) + allt(userctrl.f5) + substr(THIS.Value, nStart+1) This.Value = cNewText This.SelStart = nStart + Len(allt(userctrl.f5)) NODEFAULT CASE nKeyCode = -5 && F6 cNewText = LEFT(THIS.Value, nStart) + allt(userctrl.f6) + substr(THIS.Value, nStart+1) This.Value = cNewText This.SelStart = nStart + Len(allt(userctrl.f6)) NODEFAULT CASE nKeyCode = -6 && F7 cNewText = LEFT(THIS.Value, nStart) + allt(userctrl.f7) + substr(THIS.Value, nStart+1) This.Value = cNewText This.SelStart = nStart + Len(allt(userctrl.f7)) NODEFAULT CASE nKeyCode = 48 .and. nShiftAltCtrl = 2 && Cntl+0 pressed * do nothing at all NODEFAULT ENDCASE ENDPROC ENDDEFINEbut only with standard keys, do not try to press any of F keys, because I didn't have userctrl table (object?)