6 #include "wine/obj_base.h"
7 #include "wine/obj_enumidlist.h"
8 #include "wine/obj_shellfolder.h"
12 #include "winversion.h"
13 #include "shell32_main.h"
17 BOOL WINAPI
FileMenu_DeleteAllItems (HMENU hMenu
);
19 /*************************************************************************
20 * FileMenu_Create [SHELL32.114]
23 HMENU WINAPI
FileMenu_Create (
24 COLORREF crBorderColor
,
30 HMENU ret
= CreatePopupMenu();
32 FIXME(shell
,"0x%08lx 0x%08x 0x%08x 0x%08x 0x%08x ret=0x%08x\n",
33 crBorderColor
, nBorderWidth
, hBorderBmp
, nSelHeight
, uFlags
, ret
);
38 /*************************************************************************
39 * FileMenu_Destroy [SHELL32.118]
44 void WINAPI
FileMenu_Destroy (HMENU hMenu
)
46 TRACE(shell
,"0x%08x\n", hMenu
);
47 FileMenu_DeleteAllItems (hMenu
);
51 /*************************************************************************
52 * FileMenu_AppendItemAW [SHELL32.115]
55 BOOL WINAPI
FileMenu_AppendItemAW(
63 LPSTR lpszText
= (LPSTR
)lpText
;
65 ZeroMemory (&mii
, sizeof(MENUITEMINFOA
));
67 if (VERSION_OsIsUnicode() && (lpszText
!=FM_SEPARATOR
))
68 lpszText
= HEAP_strdupWtoA ( GetProcessHeap(),0, lpText
);
70 FIXME(shell
,"0x%08x %s 0x%08x 0x%08x 0x%08x 0x%08x\n",
71 hMenu
, (lpszText
!=FM_SEPARATOR
) ? lpszText
: NULL
,
72 uID
, icon
, hMenuPopup
, nItemHeight
);
74 mii
.cbSize
= sizeof(mii
);
78 mii
.fMask
= MIIM_SUBMENU
| MIIM_TYPE
| MIIM_DATA
;;
79 mii
.hSubMenu
= hMenuPopup
;
80 mii
.fType
= MFT_STRING
;
81 mii
.dwTypeData
= lpszText
;
83 else if (lpText
== FM_SEPARATOR
)
84 { mii
.fMask
= MIIM_ID
| MIIM_TYPE
;
85 mii
.fType
= MFT_SEPARATOR
;
89 mii
.fMask
= MIIM_ID
| MIIM_TYPE
| MIIM_STATE
;
90 mii
.dwTypeData
= lpszText
;
91 mii
.fState
= MFS_ENABLED
| MFS_DEFAULT
;
92 mii
.fType
= MFT_STRING
;
96 InsertMenuItemA (hMenu
, (UINT
)-1, TRUE
, &mii
);
98 if (VERSION_OsIsUnicode())
99 HeapFree( GetProcessHeap(), 0, lpszText
);
105 /*************************************************************************
106 * FileMenu_InsertUsingPidl [SHELL32.110]
109 * uEnumFlags any SHCONTF flag
111 int WINAPI
FileMenu_InsertUsingPidl (
117 LPFNFMCALLBACK lpfnCallback
)
119 IShellFolder
*lpsf
, *lpsf2
;
122 LPITEMIDLIST pidlTemp
=0;
124 char sTemp
[MAX_PATH
];
125 int NumberOfItems
= 0;
127 FIXME(shell
,"0x%08x 0x%08x %p 0x%08x 0x%08x %p\n",
128 hMenu
, uID
, pidl
, uFlags
, uEnumFlags
, lpfnCallback
);
131 if (SUCCEEDED (SHGetDesktopFolder(&lpsf
)))
132 { if (SUCCEEDED(IShellFolder_BindToObject(lpsf
, pidl
,0,(REFIID
)&IID_IShellFolder
,(LPVOID
*)&lpsf2
)))
133 { if (SUCCEEDED (IShellFolder_EnumObjects(lpsf2
, 0, uEnumFlags
, &lpe
)))
134 { while (NOERROR
== IEnumIDList_Next(lpe
,1,&pidlTemp
,&ulFetched
))
135 { if (SUCCEEDED (IShellFolder_GetAttributesOf(lpsf
, 1, &pidlTemp
, &ulItemAttr
)))
136 { ILGetDisplayName( pidlTemp
, sTemp
);
137 if ( SFGAO_FOLDER
& ulItemAttr
)
138 { FileMenu_AppendItemAW (hMenu
, sTemp
, uID
, FM_BLANK_ICON
, CreatePopupMenu(), FM_DEFAULT_HEIGHT
);
141 { FileMenu_AppendItemAW (hMenu
, sTemp
, uID
, FM_BLANK_ICON
, 0, FM_DEFAULT_HEIGHT
);
144 TRACE(shell
,"enter callback\n");
145 lpfnCallback ( pidl
, pidlTemp
);
146 TRACE(shell
,"leave callback\n");
149 IEnumIDList_Release (lpe
);
151 IShellFolder_Release(lpsf2
);
153 IShellFolder_Release(lpsf
);
156 return NumberOfItems
;
159 /*************************************************************************
160 * FileMenu_ReplaceUsingPidl [SHELL32.113]
163 int WINAPI
FileMenu_ReplaceUsingPidl(
168 LPFNFMCALLBACK lpfnCallback
)
170 FIXME(shell
,"0x%08x 0x%08x %p 0x%08x %p\n",
171 hMenu
, uID
, pidl
, uEnumFlags
, lpfnCallback
);
175 /*************************************************************************
176 * FileMenu_Invalidate [SHELL32.111]
178 void WINAPI
FileMenu_Invalidate (HMENU hMenu
)
180 FIXME(shell
,"0x%08x\n",hMenu
);
183 /*************************************************************************
184 * FileMenu_FindSubMenuByPidl [SHELL32.106]
186 HMENU WINAPI
FileMenu_FindSubMenuByPidl(
190 FIXME(shell
,"0x%08x %p\n",hMenu
, pidl
);
194 /*************************************************************************
195 * FileMenu_AppendFilesForPidl [SHELL32.124]
197 HMENU WINAPI
FileMenu_AppendFilesForPidl(
202 FIXME(shell
,"0x%08x %p 0x%08x\n",hMenu
, pidl
,bAddSeperator
);
205 /*************************************************************************
206 * FileMenu_AddFilesForPidl [SHELL32.125]
209 * uEnumFlags any SHCONTF flag
211 int WINAPI
FileMenu_AddFilesForPidl (
218 LPFNFMCALLBACK lpfnCallback
)
220 FIXME(shell
,"0x%08x 0x%08x 0x%08x %p 0x%08x 0x%08x %p\n",
221 hMenu
, uReserved
, uID
, pidl
, uFlags
, uEnumFlags
, lpfnCallback
);
228 /*************************************************************************
229 * FileMenu_TrackPopupMenuEx [SHELL32.116]
231 HRESULT WINAPI
FileMenu_TrackPopupMenuEx (
239 FIXME(shell
,"0x%08x 0x%08x 0x%x 0x%x 0x%08x %p stub\n",
240 hMenu
, uFlags
, x
, y
, hWnd
, lptpm
);
241 return TrackPopupMenuEx(hMenu
, uFlags
, x
, y
, hWnd
, lptpm
);
244 /*************************************************************************
245 * FileMenu_GetLastSelectedItemPidls [SHELL32.107]
247 BOOL WINAPI
FileMenu_GetLastSelectedItemPidls(
249 LPCITEMIDLIST
*ppidlFolder
,
250 LPCITEMIDLIST
*ppidlItem
)
252 FIXME(shell
,"0x%08x %p %p\n",uReserved
, ppidlFolder
, ppidlItem
);
256 /*************************************************************************
257 * FileMenu_MeasureItem [SHELL32.112]
259 LRESULT WINAPI
FileMenu_MeasureItem(
261 LPMEASUREITEMSTRUCT lpmis
)
263 FIXME(shell
,"0x%08x %p\n", hWnd
, lpmis
);
267 /*************************************************************************
268 * FileMenu_DrawItem [SHELL32.105]
270 LRESULT WINAPI
FileMenu_DrawItem(
272 LPDRAWITEMSTRUCT lpdis
)
274 FIXME(shell
,"0x%08x %p\n", hWnd
, lpdis
);
278 /*************************************************************************
279 * FileMenu_InitMenuPopup [SHELL32.109]
282 * The filemenu is a ownerdrawn menu. Call this function responding to
286 HRESULT WINAPI
FileMenu_InitMenuPopup (DWORD hmenu
)
287 { FIXME(shell
,"hmenu=0x%lx stub\n",hmenu
);
291 /*************************************************************************
292 * FileMenu_HandleMenuChar [SHELL32.108]
294 LRESULT WINAPI
FileMenu_HandleMenuChar(
298 FIXME(shell
,"0x%08x 0x%08x\n",hMenu
,wParam
);
302 /*************************************************************************
303 * FileMenu_DeleteAllItems [SHELL32.104]
308 BOOL WINAPI
FileMenu_DeleteAllItems (HMENU hMenu
)
310 FIXME(shell
,"0x%08x stub\n", hMenu
);
315 /*************************************************************************
316 * FileMenu_DeleteItemByCmd [SHELL32.]
319 BOOL WINAPI
FileMenu_DeleteItemByCmd (HMENU hMenu
, UINT uID
)
321 TRACE(shell
,"0x%08x 0x%08x\n", hMenu
, uID
);
323 DeleteMenu(hMenu
, MF_BYCOMMAND
, uID
);
327 /*************************************************************************
328 * FileMenu_DeleteItemByIndex [SHELL32.140]
330 BOOL WINAPI
FileMenu_DeleteItemByIndex ( HMENU hMenu
, UINT uPos
)
332 TRACE(shell
,"0x%08x 0x%08x\n", hMenu
, uPos
);
334 DeleteMenu(hMenu
, MF_BYPOSITION
, uPos
);
338 /*************************************************************************
339 * FileMenu_DeleteItemByFirstID [SHELL32.141]
341 BOOL WINAPI
FileMenu_DeleteItemByFirstID(
345 TRACE(shell
,"0x%08x 0x%08x\n", hMenu
, uID
);
349 /*************************************************************************
350 * FileMenu_DeleteSeparator [SHELL32.142]
352 BOOL WINAPI
FileMenu_DeleteSeparator(HMENU hMenu
)
354 TRACE(shell
,"0x%08x\n", hMenu
);
358 /*************************************************************************
359 * FileMenu_EnableItemByCmd [SHELL32.143]
361 BOOL WINAPI
FileMenu_EnableItemByCmd(
366 TRACE(shell
,"0x%08x 0x%08x 0x%08x\n", hMenu
, uID
,bEnable
);
370 /*************************************************************************
371 * FileMenu_GetItemExtent [SHELL32.144]
374 DWORD WINAPI
FileMenu_GetItemExtent (HMENU hMenu
, UINT uPos
)
377 FIXME (shell
,"0x%08x 0x%08x\n", hMenu
, uPos
);
379 if (GetMenuItemRect(0, hMenu
, uPos
, &rect
))
380 { FIXME (shell
,"0x%04x 0x%04x 0x%04x 0x%04x\n",
381 rect
.right
, rect
.left
, rect
.top
, rect
.bottom
);
382 return ((rect
.right
-rect
.left
)<<16) + (rect
.top
-rect
.bottom
);
384 return 0x00200020; /*fixme*/
387 /*************************************************************************
388 * FileMenu_AbortInitMenu [SHELL32.120]
391 void WINAPI
FileMenu_AbortInitMenu (void)
405 /*************************************************************************
406 * SHFind_InitMenuPopup [SHELL32.149]
410 * hMenu [in] handel of menu previously created
411 * hWndParent [in] parent window
415 HRESULT WINAPI
SHFind_InitMenuPopup (HMENU hMenu
, HWND hWndParent
, DWORD w
, DWORD x
)
416 { FIXME(shell
,"hmenu=0x%08x hwnd=0x%08x 0x%08lx 0x%08lx stub\n",
417 hMenu
,hWndParent
,w
,x
);
421 /*************************************************************************
422 * Shell_MergeMenus [SHELL32.67]
425 BOOL
_SHIsMenuSeparator(HMENU hm
, int i
)
429 mii
.cbSize
= sizeof(MENUITEMINFOA
);
430 mii
.fMask
= MIIM_TYPE
;
431 mii
.cch
= 0; /* WARNING: We MUST initialize it to 0*/
432 if (!GetMenuItemInfoA(hm
, i
, TRUE
, &mii
))
436 if (mii
.fType
& MFT_SEPARATOR
)
442 #define MM_ADDSEPARATOR 0x00000001L
443 #define MM_SUBMENUSHAVEIDS 0x00000002L
444 HRESULT WINAPI
Shell_MergeMenus (HMENU hmDst
, HMENU hmSrc
, UINT uInsert
, UINT uIDAdjust
, UINT uIDAdjustMax
, ULONG uFlags
)
447 BOOL bAlreadySeparated
;
448 MENUITEMINFOA miiSrc
;
450 UINT uTemp
, uIDMax
= uIDAdjust
;
452 FIXME(shell
,"hmenu1=0x%04x hmenu2=0x%04x 0x%04x 0x%04x 0x%04x 0x%04lx stub\n",
453 hmDst
, hmSrc
, uInsert
, uIDAdjust
, uIDAdjustMax
, uFlags
);
455 if (!hmDst
|| !hmSrc
)
459 nItem
= GetMenuItemCount(hmDst
);
460 if (uInsert
>= (UINT
)nItem
)
461 { uInsert
= (UINT
)nItem
;
462 bAlreadySeparated
= TRUE
;
465 { bAlreadySeparated
= _SHIsMenuSeparator(hmDst
, uInsert
);;
467 if ((uFlags
& MM_ADDSEPARATOR
) && !bAlreadySeparated
)
468 { /* Add a separator between the menus */
469 InsertMenuA(hmDst
, uInsert
, MF_BYPOSITION
| MF_SEPARATOR
, 0, NULL
);
470 bAlreadySeparated
= TRUE
;
474 /* Go through the menu items and clone them*/
475 for (nItem
= GetMenuItemCount(hmSrc
) - 1; nItem
>= 0; nItem
--)
476 { miiSrc
.cbSize
= sizeof(MENUITEMINFOA
);
477 miiSrc
.fMask
= MIIM_STATE
| MIIM_ID
| MIIM_SUBMENU
| MIIM_CHECKMARKS
| MIIM_TYPE
| MIIM_DATA
;
478 /* We need to reset this every time through the loop in case
479 menus DON'T have IDs*/
480 miiSrc
.fType
= MFT_STRING
;
481 miiSrc
.dwTypeData
= szName
;
482 miiSrc
.dwItemData
= 0;
483 miiSrc
.cch
= sizeof(szName
);
485 if (!GetMenuItemInfoA(hmSrc
, nItem
, TRUE
, &miiSrc
))
488 if (miiSrc
.fType
& MFT_SEPARATOR
)
489 { /* This is a separator; don't put two of them in a row*/
490 if (bAlreadySeparated
)
493 bAlreadySeparated
= TRUE
;
495 else if (miiSrc
.hSubMenu
)
496 { if (uFlags
& MM_SUBMENUSHAVEIDS
)
497 { /* Adjust the ID and check it*/
498 miiSrc
.wID
+= uIDAdjust
;
499 if (miiSrc
.wID
> uIDAdjustMax
)
502 if (uIDMax
<= miiSrc
.wID
)
503 { uIDMax
= miiSrc
.wID
+ 1;
507 { /* Don't set IDs for submenus that didn't have them already */
508 miiSrc
.fMask
&= ~MIIM_ID
;
510 hmSubMenu
= miiSrc
.hSubMenu
;
511 miiSrc
.hSubMenu
= CreatePopupMenu();
512 if (!miiSrc
.hSubMenu
)
515 uTemp
= Shell_MergeMenus(miiSrc
.hSubMenu
, hmSubMenu
, 0, uIDAdjust
, uIDAdjustMax
, uFlags
&MM_SUBMENUSHAVEIDS
);
519 bAlreadySeparated
= FALSE
;
522 { /* Adjust the ID and check it*/
523 miiSrc
.wID
+= uIDAdjust
;
524 if (miiSrc
.wID
> uIDAdjustMax
)
527 if (uIDMax
<= miiSrc
.wID
)
528 { uIDMax
= miiSrc
.wID
+ 1;
530 bAlreadySeparated
= FALSE
;
532 if (!InsertMenuItemA(hmDst
, uInsert
, TRUE
, &miiSrc
))
537 /* Ensure the correct number of separators at the beginning of the
538 inserted menu items*/
540 { if (bAlreadySeparated
)
541 { DeleteMenu(hmDst
, uInsert
, MF_BYPOSITION
);
545 { if (_SHIsMenuSeparator(hmDst
, uInsert
-1))
546 { if (bAlreadySeparated
)
547 { DeleteMenu(hmDst
, uInsert
, MF_BYPOSITION
);
551 { if ((uFlags
& MM_ADDSEPARATOR
) && !bAlreadySeparated
)
552 { /* Add a separator between the menus*/
553 InsertMenuA(hmDst
, uInsert
, MF_BYPOSITION
| MF_SEPARATOR
, 0, NULL
);