Retrieves a value that indicates the file path of an item of ShortCut type.
Type | Description | |||
String | A string expression that indicates the the file path. |
The following sample shows how to add an item of ShortCut type to your menu:
With PopupMenu1.Items Dim i As Item Set i = .Add("C:\Documents and Settings\All Users\Start Menu\Programs", ShortCut) i.SubMenu.Add("C:\Program Files\Internet Explorer\IEXPLORE.EXE", ShortCut, 1234).Caption = "Internet Explorer" i.SubMenu.Add("C:\WINNT\explorer.exe", ShortCut, 1235).Caption = "Windows Explorer"
The following sample shows how to add your Notepad application to menu:
PopupMenu1.Add "c:\winnt\system32\Notepad.exe", ShortCut, 1236
The following sample shows how to run the application when a item of ShortCut type is selected:
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long Private Const SW_SHOW = 5
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Dim i As Long i = PopupMenu1.ShowAtCursor If (i >= 1234) Then ' Is Internet Explorer? If i = 1234 Then ' You can call ShellExecute API and you can pass argumets ( in this case we pass "https://www.exontrol.com" for Internet Explorer item! ShellExecute 0, "open", PopupMenu1.Command(i).FilePath, "https://www.exontrol.com", "", SW_SHOW Else ' You can call ShellExecute API and you can pass argumets! ShellExecute 0, "open", PopupMenu1.Command(i).FilePath, "", "", SW_SHOW End If End If End Sub