Minor problem with RichEdit control

Started by Martin Francom, November 19, 2009, 08:09:36 PM

Previous topic - Next topic

Martin Francom

In the RichEdit Control  you can copy & paste using keyboard shortcut  ie:
   Ctrl-Insert  to copy
   Shift-Insert to paste
But you can NOT use Right Mouse Click to get the normal edit menu.  It would be nice to have RichEdit control respond normally to a right mouse click.

Paul Squires

Hi Marty,

This is not a FireFly problem, it is actually a Windows behaviour. Right-click popup menus do not show in RichEdit controls like they do in standard Edit controls (ie. TextBoxes).

Here is code that I use to display and respond to a popup menu in a RichEdit. It is from the Project Notes form in FireFly itself.


%IDC_RICHEDIT_UNDO  = %WM_USER + 101
%IDC_RICHEDIT_CUT   = %WM_USER + 102
%IDC_RICHEDIT_COPY  = %WM_USER + 103
%IDC_RICHEDIT_PASTE = %WM_USER + 104

'//
'//  Create and show the right-click popup menu for the RichEdit textboxes
'//
Function ShowRichEditPopup() As Long

    If g.hRightClickPopup Then DestroyMenu g.hRightClickPopup

    g.hRightClickPopup = CreatePopupMenu()
        AppendMenu g.hRightClickPopup, %MF_STRING, %IDC_RICHEDIT_UNDO,  "Undo"
        AppendMenu g.hRightClickPopup, %MF_SEPARATOR, 0, ""
        AppendMenu g.hRightClickPopup, %MF_STRING, %IDC_RICHEDIT_CUT,   "Cut"
        AppendMenu g.hRightClickPopup, %MF_STRING, %IDC_RICHEDIT_COPY,  "Copy"
        AppendMenu g.hRightClickPopup, %MF_STRING, %IDC_RICHEDIT_PASTE, "Paste"
       
End Function


'--------------------------------------------------------------------------------
Function FRMPROJNOTES_CUSTOM ( _
                             hWndForm      As Dword, _  ' handle of Form
                             wMsg          As Long,  _  ' type of message
                             wParam        As Dword, _  ' first message parameter
                             lParam        As Long   _  ' second message parameter
                             ) As Long

   Select Case wMsg
      Case %WM_CONTEXTMENU
          ShowRichEditPopup
          Local pt As PointApi
          GetCursorPos pt
          TrackPopupMenu g.hRightClickPopup, %TPM_LEFTALIGN Or _
                              %TPM_LEFTBUTTON, pt.x, _
                              pt.y, 0, hWndForm, ByVal %Null
         
   End Select

End Function


'--------------------------------------------------------------------------------
Function FRMPROJNOTES_WM_COMMAND ( _
                                 hWndForm     As Dword, _  ' handle of Form
                                 hWndControl  As Dword, _  ' handle of Control
                                 wNotifyCode  As Long,  _  ' notification code
                                 wID          As Long   _  ' item, control, or accelerator identifer
                                 ) As Long

   Select Case wID
   
      Case %IDC_RICHEDIT_UNDO
         SendMessage HWND_FRMPROJNOTES_RICHEDIT1, %EM_UNDO, 0, 0 
      Case %IDC_RICHEDIT_CUT
         SendMessage HWND_FRMPROJNOTES_RICHEDIT1, %WM_CUT, 0, 0 
      Case %IDC_RICHEDIT_COPY 
         SendMessage HWND_FRMPROJNOTES_RICHEDIT1, %WM_COPY, 0, 0 
      Case %IDC_RICHEDIT_PASTE
         SendMessage HWND_FRMPROJNOTES_RICHEDIT1, %WM_PASTE, 0, 0 
     
   End Select

End Function

Paul Squires
PlanetSquires Software

Pedro Marquez

If g.hRightClickPopup Then DestroyMenu g.hRightClickPopup


Paul Squires

"g" is defined as a global TYPE with hRightClickPopup as one of its members. Something like this:


Type GLOBALS_TYPE
...
...
   hRightClickPopup As DWord
...
...
End Type

Global g As GLOBALS_TYPE


Paul Squires
PlanetSquires Software

Pedro Marquez

#4
This is good and sorry for reviving the topic.




It could bring back series version of ff3



HWND_FRMPROJNOTES_RICHEDIT1

can be done globally for all


Pedro Marquez

Just need to act alone in this window RICHEDIT1

If wParam = HWND_FORM1_RICHEDIT1 Then