Forum Discussion

shreedhar_ghare's avatar
shreedhar_ghare
Copper Contributor
Aug 03, 2021
Solved

MSIX: How to handle Context menu in notepad ++ application?

Hello Team,

 

Could you please help us in handling Context Menu in the MSIX notepad ++ application? 

As per our understanding, MSIX is not supporting the full functionality of the Context Menu.

But how can we achieve the same though file association.  If possible kindly provide us sample Manifest.xml file. 

 

  • SahibiMiranshah's avatar
    SahibiMiranshah
    Aug 25, 2021

    TIMOTHY_MANGAN context menus work for Notepad++ when packaged. Try adding this to the app manifest:

     

    xmlns:desktop9="http://schemas.microsoft.com/appx/manifest/desktop/windows10/9"
    xmlns:com="http://schemas.microsoft.com/appx/manifest/com/windows10"
    <Dependencies>
    <TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.21301.0" />
    </Dependencies>
    <Extensions>
    <com:Extension Category="windows.comServer">
    <com:ComServer>
    <com:SurrogateServer DisplayName="Notepad++ Shell Extensions">
    <com:Class Id="B298D29A-A6ED-11DE-BA8C-A68E55D89593" Path="VFS\ProgramFilesX64\Notepad++\NppShell_06.dll" ThreadingModel="STA" />
    </com:SurrogateServer>
    </com:ComServer>
    </com:Extension>
    <desktop9:Extension Category="windows.fileExplorerClassicContextMenuHandler">
    <desktop9:FileExplorerClassicContextMenuHandler>
    <desktop9:ExtensionHandler Type="*" Clsid="B298D29A-A6ED-11DE-BA8C-A68E55D89593" />
    </desktop9:FileExplorerClassicContextMenuHandler>
    </desktop9:Extension>
    </Extensions>

    When you specify to use this new surrogate server in the appxmanifest, Shell creates the surrogate server out-of-proc and this server will handle creating custom IContextMenu COM object and handle data marshalling. 

3 Replies

    • TIMOTHY_MANGAN's avatar
      TIMOTHY_MANGAN
      MVP

      shreedhar_ghare

      Although Microsoft has added support in the insider build of the MSIX Packaging Tool, you are likely to find that that the context menu for that particular app will not work. The issue is that the COM based shell extension runs in-process in the explorer process and does not have access to the package app registry in the container. Most context menus don't need access to the registry and work just fine, but that one does.

       

      It is odd because it always adds the same menu item anyway; it isn't contextual.  Some have solved this in this app by adding a traditional file association with a static shell verb instead.

      • SahibiMiranshah's avatar
        SahibiMiranshah
        Icon for Microsoft rankMicrosoft

        TIMOTHY_MANGAN context menus work for Notepad++ when packaged. Try adding this to the app manifest:

         

        xmlns:desktop9="http://schemas.microsoft.com/appx/manifest/desktop/windows10/9"
        xmlns:com="http://schemas.microsoft.com/appx/manifest/com/windows10"
        <Dependencies>
        <TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.21301.0" />
        </Dependencies>
        <Extensions>
        <com:Extension Category="windows.comServer">
        <com:ComServer>
        <com:SurrogateServer DisplayName="Notepad++ Shell Extensions">
        <com:Class Id="B298D29A-A6ED-11DE-BA8C-A68E55D89593" Path="VFS\ProgramFilesX64\Notepad++\NppShell_06.dll" ThreadingModel="STA" />
        </com:SurrogateServer>
        </com:ComServer>
        </com:Extension>
        <desktop9:Extension Category="windows.fileExplorerClassicContextMenuHandler">
        <desktop9:FileExplorerClassicContextMenuHandler>
        <desktop9:ExtensionHandler Type="*" Clsid="B298D29A-A6ED-11DE-BA8C-A68E55D89593" />
        </desktop9:FileExplorerClassicContextMenuHandler>
        </desktop9:Extension>
        </Extensions>

        When you specify to use this new surrogate server in the appxmanifest, Shell creates the surrogate server out-of-proc and this server will handle creating custom IContextMenu COM object and handle data marshalling. 

Resources