event InvokeItemMenu (Command as Long)
Notifies the application once the user selects a command in the context menu.

 TypeDescription 
   Command as Long A Long expression that indicates the identifier of the command being selected.  
The InvokeItemMenu event notifies the application once the user selects an item from the control's context menu. For instance, you can use the InvokeItemMenu event to be notified when the user changes the view mode. The ViewMode property determines the current view mode. Use the InvokeMenuCommand event to be notifies when the user selects a custom command that previously was added using the QueryContextMenu event.

The following VB sample displays a message box when the user changes the view mode:

Dim nVM As EXSHELLVIEWLibCtl.ViewModeType

Private Sub ExShellView1_InvokeItemMenu(ByVal Command As Long)

    If (nVM <> ExShellView1.ViewMode) Then
        nVM = ExShellView1.ViewMode
        MsgBox "ViewMode changed to " & nVM
    End If

End Sub

Private Sub Form_Load()
    nVM = ExShellView1.ViewMode
End Sub

The sample holds the current view mode when the application starts on nVM variable. Once the InvokeItemMenu event occurs, the nVM variable is checked with the current view mode, and if it changed, a message box is displayed that the user has changed the view mode.

The following C# sample displays a message box once the user changes the control's view mode:

public Form1()
{
    InitializeComponent();

    nVM = exshellview1.ViewMode;
}

exontrol.EXSHELLVIEWLib.ViewModeType nVM = exontrol.EXSHELLVIEWLib.ViewModeType.Details;
private void exshellview1_InvokeItemMenu(object sender, int Command)
{
    if ( nVM != exshellview1.ViewMode )
    {
        nVM = exshellview1.ViewMode;
        MessageBox.Show( "ViewMode changed to " + nVM.ToString());
    }
}

The Values for the Command parameter are determined by the system, and are the same for any Windows version. For instance, the 30995 indicates a Rename operation, while the 30996 command invokes the Properties dialog of selected file or folder.

The following VB sample displays the command being performed:

Private Sub ExShellView1_InvokeItemMenu(ByVal Command As Long)
    Debug.Print Command
End Sub

 


Send comments on this topic.
© 1999-2011 Exontrol.COM, Software. All rights reserved.