473,657 Members | 2,678 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Context menu extension

yxq
Hi
I am build vb6 Context menu extension, but how to determine which popup
menu item(popupItem1 and popupItem2) was clicked?

Thanks

The code
'
' IContextMenu::Q ueryContextMenu
'
' In this function you must add your items
' to the context menu
'
Friend Function QueryContextMen u(ByVal hMenu As Long, ByVal indexMenu As
Long, ByVal idCmdFirst As Long, ByVal idCmdLast As Long, ByVal uFlags As
Long) As Long
Dim hSubMenu As Long, lIdx As Long

' Create a popup menu
hSubMenu = CreatePopupMenu ()

' Get the file count
lIdx = UBound(m_Select edFiles)

InsertMenu hSubMenu, lIdx, MF_BYPOSITION, idCmdFirst, "popupItem1 "
InsertMenu hSubMenu, lIdx, MF_BYPOSITION, idCmdFirst, "popupItem2 "
' Add the items to the context menu
InsertMenu hMenu, indexMenu, MF_BYPOSITION Or MF_SEPARATOR, 0, ByVal 0&
InsertMenu hMenu, indexMenu, MF_BYPOSITION Or MF_POPUP, hSubMenu, ByVal
"Item"
InsertMenu hMenu, indexMenu, MF_BYPOSITION Or MF_SEPARATOR, 0, ByVal 0&

' Return how many non separator
' menu items we were added
QueryContextMen u = UBound(m_Items) + 1

End Function
'
' Carries out the command associated with
' a context menu item.
'
Private Sub IContextMenu_In vokeCommand(lpi ci As shlext.CMINVOKE COMMANDINFO)
Dim Idx As Long, Verb As String, Total As Currency

On Error Resume Next

' Check if lpVerb is an string pointer
' or the ID

If (lpici.lpVerb \ &H10000) <> 0 Then

' lpVerb is a string so
' copy it from the pointer
Verb = StrFromPtrA(lpi ci.lpVerb)

' Search the items array for
' the command and convert
' it to the item index
For Idx = 0 To UBound(m_Items)
If m_Items(Idx).Ve rb = Verb Then
Exit For
End If
Next

Else
Idx = lpici.lpVerb
End If

Dim fileNames As String
' Do the action asociated
' with the menu item
Select Case Idx

Case 0

MsgBox ("popupItem1 clicked")
Case 1
MsgBox ("popupItem2 clicked")
End Select

End Sub
Nov 20 '05 #1
5 2695
"yxq" <ga***@163.ne t> schrieb
Hi
I am build vb6 Context menu extension, but how to determine which
popup
menu item(popupItem1 and popupItem2) was clicked?


Do you want to make the same code work in VB.NET? If not, you probably know
that this a VB.NET, not a VB6 group. => microsoft.publi c.vb.*
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
* "yxq" <ga***@163.ne t> scripsit:
I am build vb6 Context menu extension, but how to determine which popup
menu item(popupItem1 and popupItem2) was clicked?
Post this question to one of the VB6 groups (microsoft.publ ic.vb.*).

MsgBox ("popupItem1 clicked")
Case 1
MsgBox ("popupItem2 clicked")


Add a 'Call' in font of the 'MsgBox' or remove the "(", ")".

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3
yxq
Thanks

But i have some bemused question for a long time, please help me. Thank
you very much!
When i insert an item, and when click the item in Explorer, it works
well.
But i want to add another item, i hope the two items can respond
different command and get the selected files, but the code will not work.

*************** *************** *************** *************** *************** *
*************** ***
Friend Function QueryContextMen u(ByVal hMenu As Long, ByVal indexMenu As
Long, ByVal idCmdFirst As Long, ByVal idCmdLast As Long, ByVal uFlags As
Long) As Long
Dim hSubMenu As Long, idCmd As Long

InsertMenu hMenu, indexMenu, MF_BYPOSITION Or MF_SEPARATOR, 0, ByVal
0&
InsertMenu hMenu, indexMenu, MF_BYPOSITION Or MF_POPUP, idCmdFirst,
ByVal
"Item1"
InsertMenu hMenu, indexMenu + 1, MF_BYPOSITION Or MF_POPUP,
idCmdFirst +
1, ByVal "Item2"
InsertMenu hMenu, indexMenu, MF_BYPOSITION Or MF_SEPARATOR, 0, ByVal
0&

QueryContextMen u = UBound(m_Items) + 1
End Function

Private Sub IContextMenu_In vokeCommand(lpi ci As
shlext.CMINVOKE COMMANDINFO)
Dim Idx As Long, Verb As String, Total As Currency

On Error Resume Next

If (lpici.lpVerb \ &H10000) <> 0 Then

Verb = StrFromPtrA(lpi ci.lpVerb)

For Idx = 0 To UBound(m_Items)
If m_Items(Idx).Ve rb = Verb Then
Exit For
End If
Next

Else
Idx = lpici.lpVerb
End If

Select Case Idx
Case 0
For Idx = 0 To UBound(m_Select edFiles)
Total = Total + FileLen(m_Selec tedFiles(Idx))
Next

MsgBox ("Item1 clicked! The files " & Total)

Case 1

MsgBox ("Item2 clicked!)
End Select
End Sub

"yxq" <ga***@163.ne t> дÈëÓʼþ
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Hi
I am build vb6 Context menu extension, but how to determine which popup
menu item(popupItem1 and popupItem2) was clicked?

Thanks

The code
'
' IContextMenu::Q ueryContextMenu
'
' In this function you must add your items
' to the context menu
'
Friend Function QueryContextMen u(ByVal hMenu As Long, ByVal indexMenu As
Long, ByVal idCmdFirst As Long, ByVal idCmdLast As Long, ByVal uFlags As
Long) As Long
Dim hSubMenu As Long, lIdx As Long

' Create a popup menu
hSubMenu = CreatePopupMenu ()

' Get the file count
lIdx = UBound(m_Select edFiles)

InsertMenu hSubMenu, lIdx, MF_BYPOSITION, idCmdFirst, "popupItem1 "
InsertMenu hSubMenu, lIdx, MF_BYPOSITION, idCmdFirst, "popupItem2 "
' Add the items to the context menu
InsertMenu hMenu, indexMenu, MF_BYPOSITION Or MF_SEPARATOR, 0, ByVal 0& InsertMenu hMenu, indexMenu, MF_BYPOSITION Or MF_POPUP, hSubMenu, ByVal "Item"
InsertMenu hMenu, indexMenu, MF_BYPOSITION Or MF_SEPARATOR, 0, ByVal 0&
' Return how many non separator
' menu items we were added
QueryContextMen u = UBound(m_Items) + 1

End Function
'
' Carries out the command associated with
' a context menu item.
'
Private Sub IContextMenu_In vokeCommand(lpi ci As shlext.CMINVOKE COMMANDINFO) Dim Idx As Long, Verb As String, Total As Currency

On Error Resume Next

' Check if lpVerb is an string pointer
' or the ID

If (lpici.lpVerb \ &H10000) <> 0 Then

' lpVerb is a string so
' copy it from the pointer
Verb = StrFromPtrA(lpi ci.lpVerb)

' Search the items array for
' the command and convert
' it to the item index
For Idx = 0 To UBound(m_Items)
If m_Items(Idx).Ve rb = Verb Then
Exit For
End If
Next

Else
Idx = lpici.lpVerb
End If

Dim fileNames As String
' Do the action asociated
' with the menu item
Select Case Idx

Case 0

MsgBox ("popupItem1 clicked")
Case 1
MsgBox ("popupItem2 clicked")
End Select

End Sub

Nov 20 '05 #4
"yxq" <ga***@163.ne t> schrieb

But i have some bemused question for a long time, please help me.
Thank
you very much!

Don't you have access to the microsoft.publi c.vb.* groups?
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #5
* "yxq" <ga***@163.ne t> scripsit:
But i have some bemused question for a long time, please help me. Thank
you very much!


Did you ask in the VB6 groups?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1982
by: Marcel Hug | last post by:
Hello NG ! I would like to show the context menu which apears when i drop a file by fight mouse button. Could somebody help me ? Thanks
4
2715
by: yxq | last post by:
Hello Can anyone tell me Context Menu shell extension? It is better that provide some samples or links. Thanks
2
1526
by: elziko | last post by:
I understand how to edit the registry to add context menu items in windows for any file type. I know I can use %1 for the default value of the command key to signify the filename that has been clicked on. However, if I select multiple file names then the executable given in the default value is called multiple times. Is there an option other than %1 which will send all the filenames to the executable in one command line? Thanks!
5
2277
by: lgbjr | last post by:
Hello All, I have several Pictureboxes (linked to an AccessDB) on a VB.NET form. I would like to use a context menu to allow the user to open the picture in their default picture viewer or editor. I'd like to use the same default viewer/editor and open with... choices that are present on the users computer. Does anyone know how I can find this information programatically, so my picturebox context menu uses the same settings as the...
0
1194
by: eisbaer | last post by:
hi, i'm trying to write a shell extension for printers in c#. i use the IContextMenu and IShellExtInit interfaces to insert the menu item in the context menu - it works fine. my problem is to find out to which printer the context menu belongs. example: i have three printers installed on my system.
2
2170
by: Martin Carpella | last post by:
Hi! Can anybody give me a pointer if/how I could retrieve the Explorer context menu of a given file in C#? Thanks in advance, Martin
3
1436
by: Steven | last post by:
Hello, I want to a context menu extension dll like WinZIP, and it supports Windows Vista 32bit & 64bit. Where is it? Thank you Steven
3
5043
by: Poggs | last post by:
Hi everyone, I used the pattern for Shell Extensions for Context menu from Dino Esposito's article. However I implemented it in more than one application and it seems that those two right click functionalities cannot work together. void IContextMenu.InvokeCommand (IntPtr pici) I put more debugging information and I noticed that the two assemblies are using a common value. I haved changed their namespaces and guids to be different but...
1
2460
by: zacks | last post by:
I have figured out how to add custom menu items to various buildin context menus by looking at a project on CodeProject.com and then doing some registry searches. But I can't find how to add a complex menu item, that is, a menu item that has a submenu, or possibly a sub-submenu. I also cannot figure out how to tell windows just where in the menu the new menu item should appear, or how to add a new separator line to setoff the new menu...
0
8316
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8833
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8737
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8509
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8610
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6174
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5636
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4327
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1967
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.