How can I get standard context menu of TextBox (ThunderTextBox) using VB6 and/or WinAPI and add my own menu item(s) to it?
Someone wrote something like: "use standard menu from user32.dll, byt I can't recall the method."
So the question is... How? How to realize the functionality? Is it real at least?
P.S. The goal is to add custom item to standard context menu.
If it's your program, it isn't hard. Somebody else's program is different
So... Where's the solution? Excuse me, but u wrote nothing except common words.
The problem is:
1. Where's no WM_INIT... messages it's only WM_CONTEXTMENU - so there's no handle to menu
2. I don't know the resource identifier within system dll to direct load the menu
And u said "it's not hard"... :-/
What he said was if it is your program it is not that hard but if it is someone elses it is a different story. Meaning if you wrote the program and have the source code it is fairly easy. If someone else wrote it and you do not have the source then that is another matter.
Yes 2 days of searchin' via MSDN and internet (google, yandex, rambler).
And I didn't find anythin except "supress context menu" or "create your own menu and substitu standard one". But the question is: "How to get standard menu and change it (append item)"...
I apreciate your answers and hope your last link helps me.
Unfortunately, I think, I can't understand that I need.
Ok. Here's an attachment.
The question still "How to do?"
P.S. Sorry, I didn't specify that the application is mine. I need to extend standard textbox's context menu. Standard means that the menu is not specialy created and show but generated by the control itself.
CH "I think I'm goin' crazy"
Last edited by Psych0; October 15th, 2010 at 04:37 AM.
I created a program that helps me with my duties with my job.
There's a ServiceDesk that strores service calls. My job is analize the calls and make various report based on it. I create my own data base (mdb) and a cliend (vb6) to automate rut. (Export some information from ServiceDesk, import to my database, analyzing and reporting i've done). Now I work on my code to maximum automate rut.
There's primary actions that I've automated via hot-keys, but there's a secondary one that I wanna realize via context menu.
I just need to select part of text information in text box and have ability to select from context menu there the selection to store (there's a number of a textboxes). But there's a number of colleagues working with my application with its own habits (some of them like to use context menu instead of hot-keys to copy/paste)
I think its foolish to wrote so big project just for masking desructive things... If I would wish to write a virus or malware i'd like to use C++. :-)
I can realize my own context menu (that's not a problem) but on the spot i've got WinXP, at home Win7 and there's a different menues in both the systems. That's why I need smart solution to add items to standard menu
Think I won't be banned for offtop :-)
Last edited by Psych0; October 15th, 2010 at 11:30 AM.
This is an API that you might be able to use. Notice that the button COLORIZES the menu items.
Private Const MIM_BACKGROUND As Long = &H2
Private Const MIM_APPLYTOSUBMENUS As Long = &H80000000
Private Type MENUINFO
cbSize As Long
fMask As Long
dwStyle As Long
cyMax As Long
hbrBack As Long
dwContextHelpID As Long
dwMenuData As Long
Private Declare Function DrawMenuBar Lib "user32" _
(ByVal hWnd As Long) As Long
Private Declare Function GetSubMenu Lib "user32" _
(ByVal hMenu As Long, ByVal nPos As Long) As Long
Private Declare Function GetMenu Lib "user32" _
(ByVal hWnd As Long) As Long
Private Declare Function SetMenuInfo Lib "user32" _
(ByVal hMenu As Long, _
mi As MENUINFO) As Long
Private Declare Function CreateSolidBrush Lib "gdi32" _
(ByVal crColor As Long) As Long
Private Sub Command1_Click()
Dim mi As MENUINFO
.cbSize = Len(mi)
.fMask = MIM_BACKGROUND
.hbrBack = CreateSolidBrush(vbYellow)
SetMenuInfo GetMenu(Me.hWnd), mi 'main menu bar
.fMask = MIM_BACKGROUND Or MIM_APPLYTOSUBMENUS
.hbrBack = CreateSolidBrush(vbCyan)
SetMenuInfo GetSubMenu(GetMenu(Me.hWnd), 0), mi 'File menu (item 0)
.hbrBack = CreateSolidBrush(vbGreen)
SetMenuInfo GetSubMenu(GetMenu(Me.hWnd), 1), mi 'Edit menu (item 1)
.hbrBack = CreateSolidBrush(vbRed)
SetMenuInfo GetSubMenu(GetMenu(Me.hWnd), 2), mi 'Select menu (item 2)