RightClick on RichTextBox

Dear Guru,

     This is something tough.

     There is a AutoVerbMenu properties in Rich Text Box control. If you turn it on and right click it will show the functions like : undo, cut, paste, delete, copy.

     I want to keep all these functions and add another function to it. Selecting fonts. Basically a user should be able to say select/highlight some text and change the fonts(size, color, bold...).

     If no one can do that. Can you show me how to just set a popup menu on just within the RichTextBox (I have a menu on the form itself already, I heard they will conflict upon right click). From the menu we can go to "select fonts" and with commondialog.showFont and how to apply what the user has choosen to the selected text in the richtextbox.

    Can you also email a copy of the solution to samuel_tan@sg.ml.com

     Thanks!

Regards,
Happy
happysamAsked:
Who is Participating?
 
viktornetConnect With a Mentor Commented:
Private Declare Function SendMessage Lib "User32" Alias "SendMessageA"
  (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam
    As Long) As Long
------------------------------------------------------------------------------------
YOu can also use the function below which returns a handle so you can get some controls' handle

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
  lpClassName As String, ByVal lpWindowName As String) As Long
----------------------------------------------------------------------
Const WM_CUT = 768
Const WM_PASTE = 770
Const WM_COPY = 769
Const EM_UNDO = 199

private Sub PasteClick().........What ever procedure is this...mayb a Click() event
Dim i as Long
Dim hWnd as Long

hWnd = 'The handle of the Rich text Box

i = SendMessage(hWnd, WM_PASTE, 0, 0) 'To send wm_copy just replace it with wm_paste

End Sub

Not sure if exactly everything is implemented right but I guess as you know VB you can do the rest yourself...

Regards,
Viktor Ivanov
0
 
WxWCommented:
If I understood well you need to use a popup menu within the richedit control ? Capture the WM_RBUTTONDOWN and use the TrackPopup menu to display the popup menu .
0
 
happysamAuthor Commented:
I can add a menu to it with item of select fonts, but it will be too dificult to implement my own "cut, paste, copy, delete, undo". This will take me at least 2 to 3 man weeks!

Also about the WM_RBUTTONDOWN and TrackPopup menu where can I find reference to them? I have never used them before.

Thanks!
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
mikeblasCommented:
Why would it take you two to three man-weeks to implement cut, copy, paste, delete, and undo?  Those are all implemented by EM_messages you send to the control!

Which language are you using to write your program?

B ekiM

0
 
WxWCommented:
Correct . Just create a menu that has these commands ( that send Copy/paste etc messages ) , and add below them your own menus with menu commands .
0
 
happysamAuthor Commented:
I am using VB 5.0 to write the programme.

O.K, I checked out the APIs(first time I am trying to use them) Mikeblas and WxW and they are right. However, How then do I use the SendMessage API? There is no explanation on the parameters!

I need to know how to use WM_SETFONT, WM_CUT, WM_PASTE, WM_COPY, EM_UNDO

Also, How to use the Trackpopupmenu API? Any sample programme to send to samuel_tan@sg.ml.com?

Thanks again. Need to learn how to use API.
0
 
WxWCommented:
Well I am sorry , I don't think that VB is able to directly use the Win32 API . ( Because a friend had a similar problem and he could only use the CE toolkit , however I am not sure )
0
 
happysamAuthor Commented:
Dear WxW,
   
    Well, thanks anyway. I guess the problem is just too tough, huh?
    But just want to thank you for at least trying.

Regards,
Happy


0
 
WxWCommented:
It is not tough , but VB just permits it to happen .
I suggest you turn to Visual C++ or another C++ to have completely control of your programs
0
 
viktornetCommented:
I'm not a VB programmer but I know it's possible...Just tell me how do you declare an API and I'll show you how to do that,... For example how do you declare the code for FindWindow() Api call

something like this???

declare private function .......???What's next show me this and the rest is supose to be easy to implement :-)

Regards,
Viktor Ivanov
0
 
happysamAuthor Commented:
Viktor,

    Here's how we declare API in VB 5.0 . Cut and paste the below to the General Declaration part :

Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

     Thanks.

Regards,
Samuel Tan
0
 
viktornetCommented:
Yes I gave you the source above...Does it helps/???

//Viktor
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.