Announcement

Collapse
No announcement yet.

Notification msgs from rich edit control

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Notification msgs from rich edit control

    I am wanting to implement a rich edit control into my application, but I have not
    been able to trap notification messages from the control. The following program
    demonstrates my problem. When I start typing in the control, a MSGBOX should
    pop up if I have successfully trapped the %RN_UPDATE message, but it doesn't.

    Thanks for any help that can be offered.

    '-----------------------------------------------------------
    Code:
    #INCLUDE "WIN32API.INC" 
    #INCLUDE "COMMCTRL.INC"
    #INCLUDE "RICHEDIT.INC"
    
    %ID_RichEdit  = 500
    GLOBAL hEdit AS LONG
    DECLARE CALLBACK FUNCTION dlgCallback()
    DECLARE FUNCTION newEditProc&(BYVAL h&, BYVAL wMsg&, BYVAL wParm&, BYVAL lParm&)
    
    FUNCTION PBMAIN
       LOCAL hDlg AS LONG, hRichEd AS LONG, rText AS STRING
       LoadLibrary "RICHED32.DLL"
       CALL InitCommonControls
       DIALOG NEW 0, "DDT RichEdit demo",,, 150, 90, %WS_SYSMENU TO hDlg
       CONTROL ADD "RichEdit", hDlg, %ID_RichEdit, "", 5, 20, 120, 12, _
                   %WS_CHILD + %WS_VISIBLE, %WS_EX_CLIENTEDGE
       DIALOG SHOW MODAL hDlg CALL dlgCallback
    END FUNCTION
    
    CALLBACK FUNCTION dlgCallback()
       SELECT CASE CBMSG
       CASE %WM_INITDIALOG
          CONTROL HANDLE CBHNDL, %ID_RichEdit TO hEdit
          CONTROL SET FOCUS CBHNDL, %ID_RichEdit
       CASE %WM_COMMAND
          IF CBCTLMSG = %EN_UPDATE THEN
             MSGBOX "here
          END IF
       END SELECT
    END FUNCTION

  • #2
    You need to set the event mask for the richedit control after it
    has been created. Add the following to PBMAIN to make it work:

    CONTROL SEND hdlg, %ID_RichEdit, %EM_SETEVENTMASK, 0, %ENM_UPDATE

    (Another useful one to set is %ENM_SELCHANGE, which enables you to
    pick up all changes to the cursor's position in %WM_NOTIFY)

    ------------------

    Comment


    • #3
      Thanks Borje,

      That was exactly what I needed. After I got your help, I went back into
      win32.hlp, and it all became so clear and simple. This rich edit control
      is a lot more obscure than the regular edit control. I can't help but
      wonder how you were able to figure it all out? In any case, my hat's off
      to you. Thanks again.


      ------------------

      Comment


      • #4
        Glad to hear it helped. A really good source of knowledge for all common
        controls is the MSDN search, at http://search.microsoft.com/us/dev/


        ------------------

        Comment

        Working...
        X