PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Martin Francom on November 19, 2009, 08:09:36 PM

Title: Minor problem with RichEdit control
Post by: Martin Francom on November 19, 2009, 08:09:36 PM
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.
Title: Re: Minor problem with RichEdit control
Post by: Paul Squires on November 19, 2009, 09:07:25 PM
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

Title: Re: Minor problem with RichEdit control
Post by: Pedro Marquez on November 12, 2013, 09:45:25 AM
If g.hRightClickPopup Then DestroyMenu g.hRightClickPopup

(https://www.planetsquires.com/protect/forum/proxy.php?request=http%3A%2F%2Fimg703.imageshack.us%2Fimg703%2F4176%2Fst9n.jpg&hash=7e03f074126bd78e0489bb6a53702707103b264a)
Title: Re: Minor problem with RichEdit control
Post by: Paul Squires on November 12, 2013, 03:00:27 PM
"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


Title: Re: Minor problem with RichEdit control
Post by: Pedro Marquez on November 12, 2013, 03:54:17 PM
This is good and sorry for reviving the topic.

(https://www.planetsquires.com/protect/forum/proxy.php?request=http%3A%2F%2Fimg546.imageshack.us%2Fimg546%2F2461%2Fn93w.jpg&hash=471a89dc44283d2065631bdb4e9e4b88ab004b29)


It could bring back series version of ff3



HWND_FRMPROJNOTES_RICHEDIT1

can be done globally for all

Title: Re: Minor problem with RichEdit control
Post by: Pedro Marquez on December 25, 2013, 02:05:12 PM
Just need to act alone in this window RICHEDIT1

If wParam = HWND_FORM1_RICHEDIT1 Then