Solved

RightClick on RichTextBox

Posted on 1998-09-24
12
780 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
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 120 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
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…
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

617 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