66using Vanara . InteropServices ;
77using Vanara . PInvoke ;
88using Vanara . Windows . Shell ;
9+ using Windows . Win32 ;
10+ using Windows . Win32 . UI . WindowsAndMessaging ;
911
1012namespace Files . App . Utils . Shell
1113{
@@ -43,7 +45,7 @@ private ContextMenu(Shell32.IContextMenu cMenu, User32.SafeHMENU hMenu, IEnumera
4345
4446 public async static Task < bool > InvokeVerb ( string verb , params string [ ] filePaths )
4547 {
46- using var cMenu = await GetContextMenuForFiles ( filePaths , Shell32 . CMF . CMF_DEFAULTONLY ) ;
48+ using var cMenu = await GetContextMenuForFiles ( filePaths , PInvoke . CMF_DEFAULTONLY ) ;
4749
4850 return cMenu is not null && await cMenu . InvokeVerb ( verb ) ;
4951 }
@@ -112,7 +114,7 @@ public async Task<bool> InvokeItem(int itemID)
112114 return false ;
113115 }
114116
115- public async static Task < ContextMenu ? > GetContextMenuForFiles ( string [ ] filePathList , Shell32 . CMF flags , Func < string , bool > ? itemFilter = null )
117+ public async static Task < ContextMenu ? > GetContextMenuForFiles ( string [ ] filePathList , uint flags , Func < string , bool > ? itemFilter = null )
116118 {
117119 var owningThread = new ThreadWithMessageQueue ( ) ;
118120
@@ -140,14 +142,14 @@ public async Task<bool> InvokeItem(int itemID)
140142 } ) ;
141143 }
142144
143- public async static Task < ContextMenu ? > GetContextMenuForFiles ( ShellItem [ ] shellItems , Shell32 . CMF flags , Func < string , bool > ? itemFilter = null )
145+ public async static Task < ContextMenu ? > GetContextMenuForFiles ( ShellItem [ ] shellItems , uint flags , Func < string , bool > ? itemFilter = null )
144146 {
145147 var owningThread = new ThreadWithMessageQueue ( ) ;
146148
147149 return await owningThread . PostMethod < ContextMenu > ( ( ) => GetContextMenuForFiles ( shellItems , flags , owningThread , itemFilter ) ) ;
148150 }
149151
150- private static ContextMenu ? GetContextMenuForFiles ( ShellItem [ ] shellItems , Shell32 . CMF flags , ThreadWithMessageQueue owningThread , Func < string , bool > ? itemFilter = null )
152+ private static ContextMenu ? GetContextMenuForFiles ( ShellItem [ ] shellItems , uint flags , ThreadWithMessageQueue owningThread , Func < string , bool > ? itemFilter = null )
151153 {
152154 if ( ! shellItems . Any ( ) )
153155 return null ;
@@ -159,7 +161,7 @@ public async Task<bool> InvokeItem(int itemID)
159161
160162 Shell32 . IContextMenu menu = sf . GetChildrenUIObjects < Shell32 . IContextMenu > ( default , shellItems ) ;
161163 var hMenu = User32 . CreatePopupMenu ( ) ;
162- menu . QueryContextMenu ( hMenu , 0 , 1 , 0x7FFF , flags ) ;
164+ menu . QueryContextMenu ( hMenu , 0 , 1 , 0x7FFF , ( Shell32 . CMF ) flags ) ;
163165 var contextMenu = new ContextMenu ( menu , hMenu , shellItems . Select ( x => x . ParsingName ) , owningThread , itemFilter ) ;
164166 contextMenu . EnumMenuItems ( hMenu , contextMenu . Items ) ;
165167
@@ -174,10 +176,10 @@ public async Task<bool> InvokeItem(int itemID)
174176
175177 public static async Task WarmUpQueryContextMenuAsync ( )
176178 {
177- using var cMenu = await GetContextMenuForFiles ( new string [ ] { $@ "{ Constants . UserEnvironmentPaths . SystemDrivePath } \" } , Shell32 . CMF . CMF_NORMAL ) ;
179+ using var cMenu = await GetContextMenuForFiles ( new string [ ] { $@ "{ Constants . UserEnvironmentPaths . SystemDrivePath } \" } , PInvoke . CMF_NORMAL ) ;
178180 }
179181
180- private void EnumMenuItems ( HMENU hMenu , List < Win32ContextMenuItem > menuItemsResult , bool loadSubenus = false )
182+ private void EnumMenuItems ( Vanara . PInvoke . HMENU hMenu , List < Win32ContextMenuItem > menuItemsResult , bool loadSubenus = false )
181183 {
182184 var itemCount = User32 . GetMenuItemCount ( hMenu ) ;
183185
@@ -211,12 +213,12 @@ private void EnumMenuItems(HMENU hMenu, List<Win32ContextMenuItem> menuItemsResu
211213 continue ;
212214 }
213215
214- menuItem . Type = ( MenuItemType ) menuItemInfo . fType ;
216+ menuItem . Type = ( MENU_ITEM_TYPE ) menuItemInfo . fType ;
215217
216218 // wID - idCmdFirst
217219 menuItem . ID = ( int ) ( menuItemInfo . wID - 1 ) ;
218220
219- if ( menuItem . Type == MenuItemType . MFT_STRING )
221+ if ( menuItem . Type == MENU_ITEM_TYPE . MFT_STRING )
220222 {
221223 Debug . WriteLine ( "Item {0} ({1}): {2}" , index , menuItemInfo . wID , menuItemInfo . dwTypeData ) ;
222224
@@ -244,7 +246,7 @@ private void EnumMenuItems(HMENU hMenu, List<Win32ContextMenuItem> menuItemsResu
244246 }
245247 }
246248
247- if ( menuItemInfo . hSubMenu != HMENU . NULL )
249+ if ( menuItemInfo . hSubMenu != Vanara . PInvoke . HMENU . NULL )
248250 {
249251 Debug . WriteLine ( "Item {0}: has submenu" , index ) ;
250252 var subItems = new List < Win32ContextMenuItem > ( ) ;
0 commit comments