Solved

RightClick on RichTextBox

Posted on 1998-09-24
12
763 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 6

Expert Comment

by:WxW
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:happysam
Comment Utility
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
Comment Utility
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
Comment Utility
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 120 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Yes I gave you the source above...Does it helps/???

//Viktor
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now