Results 1 to 3 of 3

Thread: Exposing the IContextMenu in a different way :)

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2023
    Posts
    976

    Exposing the IContextMenu in a different way :)

    I did find a intressting shell32 API in the MSDN which not have been outed before in this forum. I tried it but I did get a very unexpected error. Maybe we can cooperate to make this work?
    This API on success returns a pointer to IContextMenu interface.

    Code:
    Public Declare Function SHFind_InitMenuPopup Lib "shell32.dll" (ByVal hMenu As Long, ByVal hwndOwner As Long, ByVal iCmdFirst As Long, ByVal iCmdLast As Long) As Long
    
    Public Sub GetIContextMenu(Optional ByVal hPopMenu As Long, Optional ByVal hwndOwner As Long)
      Dim ppICM As Long
      Dim pICM As IContextMenu
      Dim hr As Long
      
      If hPopMenu = 0 Then hPopMenu = CreatePopupMenu()
      
      If hPopMenu <> 0 Then
        ppICM = SHFind_InitMenuPopup(hPopMenu, hwndOwner, 1, &HFFFF)
      
        If ppICM > 0 Then
          MoveMemory pICM, ppICM, 4
          pICM.QueryContextMenu hPopMenu, 0, 1, &HFFFF, CMF_EXPLORE Or CMF_CANRENAME '<-- This is giving me a unexpected error 445 - Object doesn't support this action.
        End If
      End If
      
    End Sub

  2. #2
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    7,667

    Re: Exposing the IContextMenu in a different way :)

    Retrieves the IContextMenu instance for the submenu of options displayed for the Search entry in the Classic style Start menu.
    Classic style start menu doesn't exist on Windows 10 or 11.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2023
    Posts
    976

    Re: Exposing the IContextMenu in a different way :)

    What a pitty
    But If anyone will work on it, it will work for any Win prior to version 10.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width