Option Explicit
Private DeleteIndex As Integer
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Sub cmdBar_RequestNewInstance(Index As Integer, ctl As Object)
Dim lNewIndex As Long
lNewIndex = cmdBar.UBound + 1
Load cmdBar(lNewIndex)
cmdBar(lNewIndex).Align = 0
Set ctl = cmdBar(lNewIndex)
End Sub
Private Sub createCommandBars()
Dim Bar As cCommandBar
Dim btn As cButton
Dim btns As cCommandBarButtons
' --------------------------------------------------------
'
' create the items we're going to use.
' Buttons and CommandBars are global: it doesn't matter
' which control instance you use to create them,
' the other toolbars will reflect the same set of items.
' Remember the command bars are global to your *project*
' not just the form that holds the controls
'
' --------------------------------------------------------
With cmdBar(0)
With .Buttons
Set btn = .Add("frmMachineDistributionPopUP", , "Popup")
btn.ShowCaptionInToolbar = True
Set btn = .Add("PopUP", , "Popup")
btn.ShowCaptionInToolbar = True
.Add "ANM", 0, " Add New Machine", eNormal, "Add New Machine Drawing"
.Add "ExitfrmMachineDistribution", 1, " Exit Form", eNormal, "Exit Form"
.Add "WRRF", 0, " Register / Re-allocation", eNormal, "Registratration / Reallocation of Machine"
End With
' Top level menu:
Set Bar = .CommandBars.Add("MENU", "Menu")
Set btns = Bar.Buttons
btns.Add .Buttons("PopUP")
'frmMachineDesc
Set Bar = .CommandBars.Add("EDITMENU")
Set btns = Bar.Buttons
btns.Add .Buttons("WRRF")
.Buttons("PopUP").Bar = Bar
' Top level menu: frmMachinedistribution
Set Bar = .CommandBars.Add("frmMachineDistributionMENU", "Menu")
Set btns = Bar.Buttons
btns.Add .Buttons("frmMachineDistributionPopUP")
'frmMachinedistribution
Set Bar = .CommandBars.Add("frmMachineDistributionEDITMENU")
Set btns = Bar.Buttons
btns.Add .Buttons("ANM")
btns.Add .Buttons("ExitfrmMachineDistribution")
.Buttons("frmMachineDistributionPopUP").Bar = Bar
End With
End Sub
Private Sub Form_Load()
createCommandBars
cmdBar(0).ToolbarImageList = ImageList2
cmdBar(0).MenuImageList = ImageList2
cmdBar(0).MainMenu = True
cmdBar(0).Toolbar = cmdBar(0).CommandBars("EDITMENU")
End Sub
Private Sub lvwMachineList_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim Pt As POINTAPI
GetCursorPos Pt
If Button = 2 Then
Dim xPixels As Long
Dim yPixels As Long
xPixels = Pt.X
yPixels = Pt.Y
cmdBar(0).ShowPopupMenu xPixels, yPixels, cmdBar(0).CommandBars("EDITMENU")
End If
End Sub