Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

RightClick on RichTextBox

Posted on 1998-09-24
12
Medium Priority
?
786 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
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

715 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