Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

RightClick on RichTextBox

Posted on 1998-09-24
12
Medium Priority
?
792 Views
Last Modified: 2013-12-03
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
0
Comment
Question by:happysam
  • 4
  • 4
  • 3
  • +1
12 Comments
 
LVL 6

Expert Comment

by:WxW
ID: 1414766
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
 

Author Comment

by:happysam
ID: 1414767
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
 
LVL 11

Expert Comment

by:mikeblas
ID: 1414768
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
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 
LVL 6

Expert Comment

by:WxW
ID: 1414769
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
 

Author Comment

by:happysam
ID: 1414770
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
 
LVL 6

Expert Comment

by:WxW
ID: 1414771
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
 

Author Comment

by:happysam
ID: 1414772
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
 
LVL 6

Expert Comment

by:WxW
ID: 1414773
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
 
LVL 10

Expert Comment

by:viktornet
ID: 1414774
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
 
LVL 10

Accepted Solution

by:
viktornet earned 360 total points
ID: 1414775
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
 

Author Comment

by:happysam
ID: 1414776
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
 
LVL 10

Expert Comment

by:viktornet
ID: 1414777
Yes I gave you the source above...Does it helps/???

//Viktor
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question