October 29, 2025, 05:46:05 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Detecting Keypress

Started by ckoehn, February 14, 2010, 04:21:26 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ckoehn

How do you detect a keypress in a richedit control?  I need to detect when F3 is pressed and I can't seem to find out how to do that.

Thanks,
Clint

LarryMc

some CBasic code that can be used/converted

SETID "ENMKEYEVENTS",0x10000
SETID "ENMMOUSEEVENTS",0x20000
SETID "ENMSGFILTER",0x700
TYPE MSGFILTER
    def hwndFrom:INT
    def idFrom:INT
    def code:INT
    def msg:INT
   def wparam:INT
   def lparam:INT
ENDTYPE
DEF mf:MSGFILTER
DEF mem:MEMORY

CONTROL win,"RE,,0,0,632,212,@CTEDITMULTI|@VSCROLL|@CTEDITRETURN,501"
'Set the font of the Rich Text Box Control
CONTROLCMD win,501,@RTSETDEFAULTFONT,"Arial",10,bold,0
'Set up for the syntax highlighting
CONTROLCMD win,501,@RTSETEVENTMASK,@ENMKEYEVENTS|@ENM_MOUSEEVENTS
SETFOCUS win,501

CASE @IDCONTROL
   SELECT @CONTROLID
   CASE 501
    'Code for syntax highlighting
    IF @NOTIFYCODE = @ENMSGFILTER
   'read in the MSGFILTER structure
    mem = @QUAL
    READMEM mem,1,mf
   'at this point the keyboard event
    'is in mf.msg and the keyboard code is in mf.wparam
    'the event can be things like @IDCHAR
  IF mf.msg = @IDCHAR
   key = mf.wparam
      'Here is where you would check for the enter key CHR$(13)
      'If key = CHR$(13)
           Code here
      'EndIF
          ENDIF
       ENDIF
ENDSELECT

should give you the idea

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

ckoehn

Thanks, Larry.

Will give it a try.

Later,
Clint