ReactOS 0.4.17-dev-1190-g4c812f4
CMenuToolbars.cpp
Go to the documentation of this file.
1/*
2 * Shell Menu Band
3 *
4 * Copyright 2014 David Quintana
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20#include "shellmenu.h"
21#include <commoncontrols.h>
22#include <shlwapi_undoc.h>
23#include <uxtheme.h>
24#include <vssym32.h>
25
26#include "CMenuBand.h"
27#include "CMenuToolbars.h"
28
29#define IDS_MENU_EMPTY 34561
30
32
33// FIXME: Enable if/when wine comctl supports this flag properly
34#define USE_TBSTYLE_EX_VERTICAL 0
35
36// User-defined timer ID used while hot-tracking around the menu
37#define TIMERID_HOTTRACK 1
38
39static inline SFGAOF GetFolderItemBaseType(UINT sfgao)
40{
41 return (sfgao & SFGAO_STREAM) ? SFGAO_STREAM : (sfgao & SFGAO_FOLDER);
42}
43
45{
46 return GetFolderItemBaseType(SHELL_GetAttributesOf(psf, pidl, SFGAO_FOLDER | SFGAO_STREAM));
47}
48
50{
51 LRESULT lr;
52 bHandled = OnWinEvent(m_hWnd, uMsg, wParam, lParam, &lr) != S_FALSE;
53 return lr;
54}
55
57{
58 NMHDR * hdr;
59 HRESULT hr;
61
62 if (theResult)
63 *theResult = 0;
64 switch (uMsg)
65 {
66 case WM_COMMAND:
67 //return OnCommand(wParam, lParam, theResult);
68 return S_OK;
69
70 case WM_NOTIFY:
71 hdr = reinterpret_cast<LPNMHDR>(lParam);
72 switch (hdr->code)
73 {
75 return OnDeletingButton(reinterpret_cast<LPNMTOOLBAR>(hdr));
76
77 case PGN_CALCSIZE:
78 return OnPagerCalcSize(reinterpret_cast<LPNMPGCALCSIZE>(hdr));
79
80 case TBN_DROPDOWN:
81 return ProcessClick(reinterpret_cast<LPNMTOOLBAR>(hdr)->iItem);
82
84 //return OnHotItemChange(reinterpret_cast<LPNMTBHOTITEM>(hdr), theResult);
85 return S_OK;
86
87 case NM_CUSTOMDRAW:
88 hr = OnCustomDraw(reinterpret_cast<LPNMTBCUSTOMDRAW>(hdr), &result);
89 if (theResult)
90 *theResult = result;
91 return hr;
92
93 case TBN_GETINFOTIP:
94 return OnGetInfoTip(reinterpret_cast<LPNMTBGETINFOTIP>(hdr));
95
96 // Silence unhandled items so that they don't print as unknown
97 case RBN_CHILDSIZE:
98 return S_OK;
99
100 case TTN_GETDISPINFO:
101 return S_OK;
102
104 break;
105
106 case NM_CLICK:
107 case NM_RDOWN:
108 case NM_LDOWN:
109 break;
110
111 case TBN_GETDISPINFO:
112 break;
113
114 case TBN_BEGINDRAG:
115 case TBN_ENDDRAG:
116 break;
117
119 break;
120
121 case TBN_DRAGOUT: return S_FALSE;
122
123 default:
124 TRACE("WM_NOTIFY unknown code %d, %d\n", hdr->code, hdr->idFrom);
125 return S_OK;
126 }
127 return S_FALSE;
128 case WM_WININICHANGE:
129 if (wParam == SPI_SETFLATMENU)
130 {
131 SystemParametersInfo(SPI_GETFLATMENU, 0, &m_useFlatMenus, 0);
132 }
133 }
134
135 return S_FALSE;
136}
137
139{
140 if (m_disableMouseTrack != bDisable)
141 {
142 m_disableMouseTrack = bDisable;
143 TRACE("DisableMouseTrack %d\n", bDisable);
144 }
145 return S_OK;
146}
147
149{
150 SIZE tbs;
151 GetSizes(NULL, &tbs, NULL);
152 if (csize->dwFlag == PGF_CALCHEIGHT)
153 {
154 csize->iHeight = tbs.cy;
155 }
156 else if (csize->dwFlag == PGF_CALCWIDTH)
157 {
158 csize->iWidth = tbs.cx;
159 }
160 return S_OK;
161}
162
164{
165 bool isHot, isPopup, isActive;
166 TBBUTTONINFO btni;
167
168 switch (cdraw->nmcd.dwDrawStage)
169 {
170 case CDDS_PREPAINT:
171 *theResult = CDRF_NOTIFYITEMDRAW;
172 return S_OK;
173
175
176 HWND tlw;
178
179 // The item with an active submenu gets the CHECKED flag.
180 isHot = m_hotBar == this && (int) cdraw->nmcd.dwItemSpec == m_hotItem;
181 isPopup = m_popupBar == this && (int) cdraw->nmcd.dwItemSpec == m_popupItem;
182 isActive = (GetForegroundWindow() == tlw) || (m_popupBar == this);
183
184 if (m_hotItem < 0 && isPopup)
185 isHot = TRUE;
186
187 if ((m_useFlatMenus && isHot) || (m_initFlags & SMINIT_VERTICAL))
188 {
189 COLORREF clrText;
190 HBRUSH bgBrush;
191 RECT rc = cdraw->nmcd.rc;
192 HDC hdc = cdraw->nmcd.hdc;
193
194 // Remove HOT and CHECKED flags (will restore HOT if necessary)
195 cdraw->nmcd.uItemState &= ~(CDIS_HOT | CDIS_CHECKED);
196
197 // Decide on the colors
198 if (isHot)
199 {
200 cdraw->nmcd.uItemState |= CDIS_HOT;
201
203 bgBrush = GetSysColorBrush(m_useFlatMenus ? COLOR_MENUHILIGHT : COLOR_HIGHLIGHT);
204 }
205 else
206 {
207 clrText = GetSysColor(COLOR_MENUTEXT);
208 bgBrush = GetSysColorBrush(COLOR_MENU);
209 }
210
211 // Paint the background color with the selected color
212 FillRect(hdc, &rc, bgBrush);
213
214 // Set the text color in advance, this color will be assigned when the ITEMPOSTPAINT triggers
215 SetTextColor(hdc, clrText);
216
217 // Set the text color, will be used by the internal drawing code
218 cdraw->clrText = clrText;
219 cdraw->iListGap += 4;
220
221 // Tell the default drawing code we don't want any fanciness, not even a background.
222 *theResult = CDRF_NOTIFYPOSTPAINT | TBCDRF_NOBACKGROUND | TBCDRF_NOEDGES | TBCDRF_NOOFFSET | TBCDRF_NOMARK | 0x00800000; // FIXME: the last bit is Vista+, useful for debugging only
223 }
224 else
225 {
226 // Set the text color, will be used by the internal drawing code
227 cdraw->clrText = GetSysColor(isActive ? COLOR_MENUTEXT : COLOR_GRAYTEXT);
228
229 // Remove HOT and CHECKED flags (will restore HOT if necessary)
230 cdraw->nmcd.uItemState &= ~CDIS_HOT;
231
232 // Decide on the colors
233 if (isHot)
234 {
235 cdraw->nmcd.uItemState |= CDIS_HOT;
236 }
237
238 *theResult = 0;
239 }
240
241 return S_OK;
242
244
245 // Fetch the button style
246 btni.cbSize = sizeof(btni);
247 btni.dwMask = TBIF_STYLE;
248 GetButtonInfo(cdraw->nmcd.dwItemSpec, &btni);
249
250 // Check if we need to draw a submenu arrow
251 if (btni.fsStyle & BTNS_DROPDOWN)
252 {
253 // TODO: Support RTL text modes by drawing a leftwards arrow aligned to the left of the control
254
255 // "8" is the rightwards dropdown arrow in the Marlett font
256 WCHAR text [] = L"8";
257
258 // Configure the font to draw with Marlett, keeping the current background color as-is
259 HGDIOBJ hFontOld = SelectObject(cdraw->nmcd.hdc, m_marlett);
260 SetBkMode(cdraw->nmcd.hdc, TRANSPARENT);
261
262 // Tweak the alignment by 1 pixel so the menu draws like the Windows start menu.
263 RECT rc = cdraw->nmcd.rc;
264 rc.right += 1;
265
266 // The arrow is drawn at the right of the item's rect, aligned vertically.
268
269 SelectObject(cdraw->nmcd.hdc, hFontOld);
270 }
271 *theResult = TRUE;
272 return S_OK;
273
274 default:
275 *theResult = 0L;
276 break;
277 }
278 return S_OK;
279}
280
282 m_pager(WC_PAGESCROLLER, this),
283 m_useFlatMenus(FALSE),
284 m_disableMouseTrack(FALSE),
285 m_timerEnabled(FALSE),
286 m_menuBand(menuBand),
287 m_dwMenuFlags(0),
288 m_hasSizes(FALSE),
289 m_usePager(usePager),
290 m_hotBar(NULL),
291 m_hotItem(-1),
292 m_popupBar(NULL),
293 m_popupItem(-1),
294 m_isTrackingPopup(FALSE),
295 m_cancelingPopup(FALSE)
296{
297 m_idealSize.cx = 0;
298 m_idealSize.cy = 0;
299 m_itemSize.cx = 0;
300 m_itemSize.cy = 0;
302 0, 0, 0, 0, 0, 0, 0, 0, DEFAULT_CHARSET,
304 DEFAULT_QUALITY, FF_DONTCARE, L"Marlett");
305}
306
308{
309 if (m_hWnd)
310 {
311 ClearToolbar();
313 }
314
315 if (m_pager.m_hWnd)
316 m_pager.DestroyWindow();
317
319}
320
322{
324}
325
327{
328 if (m_hWnd == NULL)
329 return S_FALSE;
330
331 ShowWindow(fShow ? SW_SHOW : SW_HIDE);
332
333 // Ensure that the right image list is assigned to the toolbar
335
336 // For custom-drawing
337 SystemParametersInfo(SPI_GETFLATMENU, 0, &m_useFlatMenus, 0);
338
339 return S_OK;
340}
341
343{
344 if ((m_initFlags & (SMINIT_TOPLEVEL | SMINIT_VERTICAL)) == SMINIT_TOPLEVEL) // not vertical.
345 {
346 // No image list, prevents the buttons from having a margin at the left side
348 return S_OK;
349 }
350
351 // Assign the correct imagelist and padding based on the current icon size
352
353 int shiml;
354 if (m_menuBand->UseBigIcons())
355 {
356 shiml = SHIL_LARGE;
357 SetPadding(4, 0);
358 }
359 else
360 {
361 shiml = SHIL_SMALL;
362 SetPadding(4, 4);
363 }
364
365 IImageList * piml;
368 {
370 }
371 else
372 {
374 }
375 return S_OK;
376}
377
379{
380 if (m_hWnd)
382
383 if (m_pager.m_hWnd)
384 m_pager.DestroyWindow();
385
386 return S_OK;
387}
388
390{
395
396 if (dwFlags & SMINIT_VERTICAL)
397 {
398 // Activate vertical semantics
399 tbStyles |= CCS_VERT;
400
401#if USE_TBSTYLE_EX_VERTICAL
402 tbExStyles |= TBSTYLE_EX_VERTICAL;
403#endif
404 }
405
407
408 // Get a temporary rect to use while creating the toolbar window.
409 // Ensure that it is not a null rect.
410 RECT rc;
411 if (!::GetClientRect(hwndParent, &rc) ||
412 (rc.left == rc.right) ||
413 (rc.top == rc.bottom))
414 {
415 rc.left = 0;
416 rc.top = 0;
417 rc.right = 1;
418 rc.bottom = 1;
419 }
420
421 // HACK & FIXME: CORE-17505
422 HWND toolbar = CToolbar::Create(hwndParent, tbStyles, tbExStyles);
423 m_hWnd = NULL;
424 SubclassWindow(toolbar);
425
426 SetWindowTheme(m_hWnd, L"", L"");
427
428 SystemParametersInfo(SPI_GETFLATMENU, 0, &m_useFlatMenus, 0);
429
431
432 // If needed, create the pager.
433 if (m_usePager)
434 {
435 LONG pgStyles = PGS_VERT | WS_CHILD | WS_VISIBLE;
436 LONG pgExStyles = 0;
437
438 HWND hwndPager = CreateWindowEx(
439 pgExStyles, WC_PAGESCROLLER, NULL,
440 pgStyles, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
441 hwndParent, NULL, _AtlBaseModule.GetModuleInstance(), 0);
442
443 m_pager.SubclassWindow(hwndPager);
444
445 ::SetParent(m_hWnd, hwndPager);
446
447 m_pager.SendMessageW(PGM_SETCHILD, 0, reinterpret_cast<LPARAM>(m_hWnd));
448 }
449
450 // Configure the image lists
452
453 return S_OK;
454}
455
456HRESULT CMenuToolbarBase::GetSizes(SIZE* pMinSize, SIZE* pMaxSize, SIZE* pIntegralSize)
457{
458 if (pMinSize)
459 *pMinSize = m_idealSize;
460 if (pMaxSize)
461 *pMaxSize = m_idealSize;
462 if (pIntegralSize)
463 *pIntegralSize = m_itemSize;
464
465 if (m_hasSizes)
466 return S_OK;
467
468 TRACE("Sizes out of date, recalculating.\n");
469
470 if (!m_hWnd)
471 {
472 return S_OK;
473 }
474
475 // Obtain the ideal size, to be used as min and max
476 GetMaxSize(&m_idealSize);
477 GetIdealSize((m_initFlags & SMINIT_VERTICAL) != 0, &m_idealSize);
478
479 TRACE("Ideal Size: (%d, %d) for %d buttons\n", m_idealSize, GetButtonCount());
480
481 // Obtain the button size, to be used as the integral size
482 DWORD size = GetButtonSize();
486
487 if (pMinSize)
488 *pMinSize = m_idealSize;
489 if (pMaxSize)
490 *pMaxSize = m_idealSize;
491 if (pIntegralSize)
492 *pIntegralSize = m_itemSize;
493
494 return S_OK;
495}
496
498{
499 // Update the toolbar or pager to fit the requested rect
500 // If we have a pager, set the toolbar height to the ideal height of the toolbar
501 if (m_pager.m_hWnd)
502 {
504 m_pager.SetWindowPos(NULL, x, y, cx, cy, 0);
505 }
506 else
507 {
508 SetWindowPos(NULL, x, y, cx, cy, 0);
509 }
510
511 // In a vertical menu, resize the buttons to fit the width
512 if (m_initFlags & SMINIT_VERTICAL)
513 {
514 DWORD btnSize = GetButtonSize();
515 SetButtonSize(cx, GET_Y_LPARAM(btnSize));
516 }
517
518 return S_OK;
519}
520
522{
523 if (m_hWnd && m_hWnd == hwnd) return S_OK;
524 if (m_pager.m_hWnd && m_pager.m_hWnd == hwnd) return S_OK;
525 return S_FALSE;
526}
527
529{
530 if (!phwnd)
531 return E_FAIL;
532
533 if (m_pager.m_hWnd)
534 *phwnd = m_pager.m_hWnd;
535 else
536 *phwnd = m_hWnd;
537
538 return S_OK;
539}
540
542{
543 INT index;
545
546 INT iItem = tip->iItem;
547
548 GetDataFromId(iItem, &index, &dwData);
549
550 return InternalGetTooltip(iItem, index, dwData, tip->pszText, tip->cchTextMax);
551}
552
554{
556 {
557 bHandled = FALSE;
558 return 0;
559 }
560
562
563 if (!m_timerEnabled)
564 return 0;
565
567
568 if (m_hotItem < 0)
569 return 0;
570
571 // Returns S_FALSE if the current item did not show a submenu
573 if (hr != S_FALSE)
574 return 0;
575
576 // If we didn't switch submenus, cancel the current popup regardless
577 if (m_popupBar)
578 {
581 return 0;
582 }
583
584 return 0;
585}
586
588{
589 if (m_timerEnabled)
590 {
593 return S_OK;
594 }
595 return S_FALSE;
596}
597
599{
600 // Ignore the change if it already matches the stored info
601 if (m_hotBar == toolbar && m_hotItem == item)
602 return S_FALSE;
603
604 // Prevent a change of hot item if the change was triggered by the mouse,
605 // and mouse tracking is disabled.
607 {
608 TRACE("Hot item change prevented by DisableMouseTrack\n");
609 return S_OK;
610 }
611
612 // Notify the toolbar if the hot-tracking left this toolbar
613 if (m_hotBar == this && toolbar != this)
614 {
615 SetHotItem(-1);
616 }
617
618 TRACE("Hot item changed from %p %p, to %p %p\n", m_hotBar, m_hotItem, toolbar, item);
619 m_hotBar = toolbar;
620 m_hotItem = item;
621
622 if (m_hotBar == this)
623 {
624 if (m_isTrackingPopup && !(m_initFlags & SMINIT_VERTICAL))
625 {
626 // If the menubar has an open submenu, switch to the new item's submenu immediately
628 }
629 else if (dwFlags & HICF_MOUSE)
630 {
631 // Vertical menus show/hide the submenu after a delay,
632 // but only with the mouse.
633 if (m_initFlags & SMINIT_VERTICAL)
634 {
635 DWORD elapsed = 0;
636 SystemParametersInfo(SPI_GETMENUSHOWDELAY, 0, &elapsed, 0);
637 SetTimer(TIMERID_HOTTRACK, elapsed);
639 TRACE("SetTimer called with m_hotItem=%d\n", m_hotItem);
640 }
641 }
642 else
643 {
645 info.cbSize = sizeof(info);
646 info.dwMask = 0;
647
648 int index = GetButtonInfo(item, &info);
649
650 SetHotItem(index);
651 }
652 }
653
655 return S_OK;
656}
657
659{
660 // Ignore the change if it already matches the stored info
661 if (m_popupBar == toolbar && m_popupItem == item)
662 return S_FALSE;
663
664 // Notify the toolbar if the popup-tracking this toolbar
665 if (m_popupBar == this && toolbar != this)
666 {
667 CheckButton(m_popupItem, FALSE);
669 }
670
671 m_popupBar = toolbar;
673
674 if (m_popupBar == this)
675 {
676 CheckButton(m_popupItem, TRUE);
677 }
678
680 return S_OK;
681}
682
684{
685 TBBUTTON btn;
686 INT idx = (INT)wParam;
687
688 if (m_hotBar != this)
689 return S_FALSE;
690
691 if (idx < 0)
692 return S_FALSE;
693
694 if (!GetButton(idx, &btn))
695 return E_FAIL;
696
697 if (m_hotItem == btn.idCommand)
698 return S_OK;
699
700 if (m_popupItem == btn.idCommand)
701 return S_OK;
702
703 return S_FALSE;
704}
705
707{
708 TBBUTTON btn;
709 BOOL wasTracking = LOWORD(lParam);
710 BOOL mouse = HIWORD(lParam);
711 INT idx = (INT)wParam;
712
713 if (idx < 0)
714 {
717 }
718
719 if (!GetButton(idx, &btn))
720 return E_FAIL;
721
722 TRACE("ChangeTrackedItem %d, %d\n", idx, wasTracking);
723 m_isTrackingPopup = wasTracking;
724 return m_menuBand->_ChangeHotItem(this, btn.idCommand, mouse ? HICF_MOUSE : 0);
725}
726
728{
729 // Calculate the submenu position and exclude area
730 RECT rc = { 0 };
731
732 if (!GetItemRect(index, &rc))
733 return E_FAIL;
734
735 POINT a = { rc.left, rc.top };
736 POINT b = { rc.right, rc.bottom };
737
740
741 POINTL pt = { a.x, b.y };
742 RECTL rcl = { a.x, a.y, b.x, b.y };
743
744 if (m_initFlags & SMINIT_VERTICAL)
745 {
746 // FIXME: Hardcoding this here feels hacky.
747 if (IsAppThemed())
748 {
749 pt.x = b.x - 1;
750 pt.y = a.y - 1;
751 }
752 else
753 {
754 pt.x = b.x - 3;
755 pt.y = a.y - 3;
756 }
757 }
758
759 // Display the submenu
761
762 m_menuBand->_ChangePopupItem(this, iItem);
763 m_menuBand->_OnPopupSubMenu(childShellMenu, &pt, &rcl, keyInitiated);
764
765 return S_OK;
766}
767
769{
770 // Calculate the submenu position and exclude area
771 RECT rc = { 0 };
772
773 if (!GetItemRect(index, &rc))
774 return E_FAIL;
775
776 POINT a = { rc.left, rc.top };
777 POINT b = { rc.right, rc.bottom };
778
781
782 POINT pt = { a.x, b.y };
783 RECT rcl = { a.x, a.y, b.x, b.y };
784
785 if (m_initFlags & SMINIT_VERTICAL)
786 {
787 pt.x = b.x;
788 pt.y = a.y;
789 }
790
791 HMENU popup = GetSubMenu(menu, index);
792
793 // Display the submenu
795 m_menuBand->_ChangePopupItem(this, iItem);
796 m_menuBand->_TrackSubMenu(popup, pt.x, pt.y, rcl);
799
800 return S_OK;
801}
802
804{
805 // Cancel submenus
807 if (m_popupBar)
809
810 // Display the context menu
811 return m_menuBand->_TrackContextMenu(contextMenu, pt.x, pt.y);
812}
813
815{
817 TRACE("BeforeCancelPopup\n");
818 return S_OK;
819}
820
822{
824 {
825 TRACE("Item click prevented by DisableMouseTrack\n");
826 return S_OK;
827 }
828
829 // If a button is clicked while a submenu was open, cancel the submenu.
830 if (!(m_initFlags & SMINIT_VERTICAL) && m_isTrackingPopup)
831 {
832 TRACE("OnCommand cancelled because it was tracking submenu.\n");
833 return S_FALSE;
834 }
835
836 if (PopupItem(iItem, FALSE) == S_OK)
837 {
838 TRACE("PopupItem returned S_OK\n");
839 return S_FALSE;
840 }
841
842 TRACE("Executing...\n");
843
844 return m_menuBand->_MenuItemSelect(MPOS_EXECUTE);
845}
846
848{
849 INT index;
851
852 GetDataFromId(iItem, &index, &data);
853
856
857 return InternalContextMenu(iItem, index, data, pt);
858}
859
861{
862 TBBUTTON btn;
863
864 GetButton(iIndex, &btn);
865
866 // Ignore disabled items
867 if (!(btn.fsState & TBSTATE_ENABLED))
868 return S_OK;
869
870 if ((m_initFlags & SMINIT_VERTICAL)
871 || m_popupBar
873 {
875 return S_OK;
876 }
877
878 return ProcessClick(btn.idCommand);
879}
880
882{
883 TBBUTTON btn;
884
886
887 if (!(m_initFlags & SMINIT_VERTICAL))
888 return S_OK;
889
890 GetButton(iIndex, &btn);
891
892 // Ignore disabled items
893 if (!(btn.fsState & TBSTATE_ENABLED))
894 return S_OK;
895
896 if (isLButton)
897 return ProcessClick(btn.idCommand);
898 else
899 return ProcessContextMenu(btn.idCommand);
900}
901
903{
905
906 m_executeItem = iItem;
908}
909
911{
913}
914
916{
917 int prev = m_hotItem;
918 int index = -1;
919
920 if (dwSelectType != 0xFFFFFFFF)
921 {
922 int count = GetButtonCount();
923
924 if (dwSelectType == VK_HOME)
925 {
926 index = 0;
927 dwSelectType = VK_DOWN;
928 }
929 else if (dwSelectType == VK_END)
930 {
931 index = count - 1;
932 dwSelectType = VK_UP;
933 }
934 else
935 {
936 if (m_hotItem >= 0)
937 {
938 TBBUTTONINFO info = { 0 };
939 info.cbSize = sizeof(TBBUTTONINFO);
940 info.dwMask = 0;
941 index = GetButtonInfo(m_hotItem, &info);
942 }
943
944 if (index < 0)
945 {
946 if (dwSelectType == VK_UP)
947 {
948 index = count - 1;
949 }
950 else if (dwSelectType == VK_DOWN)
951 {
952 index = 0;
953 }
954 }
955 else
956 {
957 if (dwSelectType == VK_UP)
958 {
959 index--;
960 }
961 else if (dwSelectType == VK_DOWN)
962 {
963 index++;
964 }
965 }
966 }
967
968 TBBUTTON btn = { 0 };
969 while (index >= 0 && index < count)
970 {
971 DWORD res = GetButton(index, &btn);
972 if (!res)
973 return E_FAIL;
974
975 if (btn.dwData)
976 {
977 if (prev != btn.idCommand)
978 {
979 TRACE("Setting Hot item to %d\n", index);
980 if (!(m_initFlags & SMINIT_VERTICAL) && m_isTrackingPopup)
981 {
982 HWND tlw;
984 ::SendMessageW(tlw, WM_CANCELMODE, 0, 0);
986 }
987 else
988 m_menuBand->_ChangeHotItem(this, btn.idCommand, 0);
989 }
990 return S_OK;
991 }
992
993 if (dwSelectType == VK_UP)
994 {
995 index--;
996 }
997 else if (dwSelectType == VK_DOWN)
998 {
999 index++;
1000 }
1001 }
1002
1003 return S_FALSE;
1004 }
1005
1006 if (prev != -1)
1007 {
1008 TRACE("Setting Hot item to null\n");
1010 }
1011
1012 return S_FALSE;
1013}
1014
1015HRESULT CMenuToolbarBase::AddButton(DWORD commandId, LPCWSTR caption, BOOL hasSubMenu, INT iconId, DWORD_PTR buttonData, BOOL last)
1016{
1017 TBBUTTON tbb = { 0 };
1018
1020#if !USE_TBSTYLE_EX_VERTICAL
1021 if (!last && (m_initFlags & SMINIT_VERTICAL))
1022 tbb.fsState |= TBSTATE_WRAP;
1023#endif
1025
1026 if (hasSubMenu && (m_initFlags & SMINIT_VERTICAL))
1027 tbb.fsStyle |= BTNS_DROPDOWN;
1028
1029 if (!(m_initFlags & SMINIT_VERTICAL))
1030 tbb.fsStyle |= BTNS_AUTOSIZE;
1031
1032 tbb.iString = (INT_PTR) caption;
1033 tbb.idCommand = commandId;
1034
1035 tbb.iBitmap = iconId;
1036 tbb.dwData = buttonData;
1037
1038 m_hasSizes = FALSE;
1039
1040 if (!AddButtons(1, &tbb))
1042 return S_OK;
1043}
1044
1046{
1047 TBBUTTON tbb = { 0 };
1048
1050#if !USE_TBSTYLE_EX_VERTICAL
1051 if (!last && (m_initFlags & SMINIT_VERTICAL))
1052 tbb.fsState |= TBSTATE_WRAP;
1053#endif
1054 tbb.fsStyle = BTNS_SEP;
1055 tbb.iBitmap = 0;
1056
1057 m_hasSizes = FALSE;
1058
1059 if (!AddButtons(1, &tbb))
1061
1062 return S_OK;
1063}
1064
1066{
1067 TBBUTTON tbb = { 0 };
1068 WCHAR MenuString[128];
1069
1070 LoadStringW(GetModuleHandle(L"shell32.dll"), IDS_MENU_EMPTY, MenuString, _countof(MenuString));
1071
1072 tbb.fsState = 0;
1073 tbb.fsStyle = 0;
1074 tbb.iString = (INT_PTR) MenuString;
1075 tbb.iBitmap = -1;
1076
1077 m_hasSizes = FALSE;
1078
1079 if (!AddButtons(1, &tbb))
1081
1082 return S_OK;
1083}
1084
1086{
1087 while (DeleteButton(0))
1088 {
1089 // empty;
1090 }
1091 m_hasSizes = FALSE;
1092 return S_OK;
1093}
1094
1096{
1097 if (pData)
1098 *pData = NULL;
1099
1100 if (pIndex)
1101 *pIndex = -1;
1102
1103 if (iItem < 0)
1104 return S_OK;
1105
1106 TBBUTTONINFO info = { 0 };
1107
1108 info.cbSize = sizeof(TBBUTTONINFO);
1109 info.dwMask = TBIF_COMMAND | TBIF_LPARAM;
1110
1111 int index = GetButtonInfo(iItem, &info);
1112 if (index < 0)
1113 return E_FAIL;
1114
1115 if (pIndex)
1116 *pIndex = index;
1117
1118 if (pData)
1119 *pData = info.lParam;
1120
1121 return S_OK;
1122}
1123
1125{
1127}
1128
1130{
1131 INT index;
1133
1134 if (iItem < 0)
1135 return S_OK;
1136
1137 if (m_popupBar == this && m_popupItem == iItem)
1138 return S_OK;
1139
1140 GetDataFromId(iItem, &index, &dwData);
1141
1143 if (hr != S_OK)
1144 return hr;
1145
1146 if (m_popupBar)
1147 {
1150 return hr;
1151 }
1152
1153 if (!(m_initFlags & SMINIT_VERTICAL))
1154 {
1155 TRACE("PopupItem non-vertical %d %d\n", index, iItem);
1156 m_menuBand->_ChangeHotItem(this, iItem, 0);
1157 }
1158
1159 return InternalPopupItem(iItem, index, dwData, keyInitiated);
1160}
1161
1163 CMenuToolbarBase(menuBand, FALSE),
1164 m_hmenu(NULL),
1165 m_hwndMenu(NULL)
1166{
1167}
1168
1170{
1171}
1172
1174 _Out_opt_ HMENU *phmenu,
1175 _Out_opt_ HWND *phwnd,
1176 _Out_opt_ DWORD *pdwFlags)
1177{
1178 if (phmenu)
1179 *phmenu = m_hmenu;
1180 if (phwnd)
1181 *phwnd = m_hwndMenu;
1182 if (pdwFlags)
1183 *pdwFlags = m_dwMenuFlags;
1184
1185 return S_OK;
1186}
1187
1189 HMENU hmenu,
1190 HWND hwnd,
1191 DWORD dwFlags)
1192{
1193 m_hmenu = hmenu;
1194 m_hwndMenu = hwnd;
1196
1197 if (IsWindow())
1198 ClearToolbar();
1199
1200 return S_OK;
1201}
1202
1204{
1205 int i;
1206 int ic = GetMenuItemCount(m_hmenu);
1207
1208 if (clearFirst)
1209 {
1210 ClearToolbar();
1211 }
1212
1213 int count = 0;
1214 for (i = 0; i < ic; i++)
1215 {
1216 BOOL last = i + 1 == ic;
1217
1219
1220 info.cbSize = sizeof(info);
1221 info.dwTypeData = NULL;
1222 info.fMask = MIIM_FTYPE | MIIM_STRING | MIIM_ID;
1223
1225 {
1226 TRACE("Error obtaining info for menu item at pos=%d\n", i);
1227 continue;
1228 }
1229
1230 count++;
1231
1232 if (info.fType & MFT_SEPARATOR)
1233 {
1235 }
1236 else if (!(info.fType & MFT_BITMAP))
1237 {
1238 info.cch++;
1239 info.dwTypeData = (PWSTR) HeapAlloc(GetProcessHeap(), 0, (info.cch + 1) * sizeof(WCHAR));
1240
1243
1244 SMINFO * sminfo = new SMINFO();
1245 sminfo->dwMask = SMIM_ICON | SMIM_FLAGS;
1246
1247 HRESULT hr = m_menuBand->_CallCBWithItemId(info.wID, SMC_GETINFO, 0, reinterpret_cast<LPARAM>(sminfo));
1249 {
1250 delete sminfo;
1251 return hr;
1252 }
1253
1254 AddButton(info.wID, info.dwTypeData, info.hSubMenu != NULL, sminfo->iIcon, reinterpret_cast<DWORD_PTR>(sminfo), last);
1255
1256 HeapFree(GetProcessHeap(), 0, info.dwTypeData);
1257 }
1258 }
1259
1260 return S_OK;
1261}
1262
1264{
1265 //SMINFO * info = reinterpret_cast<SMINFO*>(dwData);
1267 return E_NOTIMPL;
1268}
1269
1271{
1272 delete reinterpret_cast<SMINFO*>(tb->tbButton.dwData);
1273 return S_OK;
1274}
1275
1277{
1278 CComPtr<IContextMenu> contextMenu;
1279 HRESULT hr = m_menuBand->_CallCBWithItemId(iItem, SMC_GETOBJECT,
1280 reinterpret_cast<WPARAM>(&IID_IContextMenu), reinterpret_cast<LPARAM>(&contextMenu));
1281 if (hr != S_OK)
1282 return hr;
1283
1284 return TrackContextMenu(contextMenu, pt);
1285}
1286
1288{
1289 return m_menuBand->_CallCBWithItemId(iItem, SMC_EXEC, 0, 0);
1290}
1291
1293{
1294 SMINFO * nfo = reinterpret_cast<SMINFO*>(dwData);
1295 if (!nfo)
1296 return E_FAIL;
1297
1298 if (nfo->dwFlags&SMIF_TRACKPOPUP)
1299 {
1300 return PopupSubMenu(iItem, index, m_hmenu);
1301 }
1302 else
1303 {
1304 CComPtr<IShellMenu> shellMenu;
1305 HRESULT hr = m_menuBand->_CallCBWithItemId(iItem, SMC_GETOBJECT, reinterpret_cast<WPARAM>(&IID_IShellMenu), reinterpret_cast<LPARAM>(&shellMenu));
1307 return hr;
1308
1309 return PopupSubMenu(iItem, index, shellMenu, keyInitiated);
1310 }
1311}
1312
1314{
1315 return ::GetSubMenu(m_hmenu, index) ? S_OK : S_FALSE;
1316}
1317
1319 CMenuToolbarBase(menuBand, TRUE),
1320 m_shellFolder(NULL),
1321 m_idList(NULL),
1322 m_hKey(NULL)
1323{
1324}
1325
1327{
1328}
1329
1331{
1332 IShellFolder * psf = (IShellFolder*) lParam;
1335 HRESULT hr = psf->CompareIDs(0, pidl1, pidl2);
1336 if (FAILED(hr))
1337 {
1338 // No way to cancel, so sort to equal.
1339 return 0;
1340 }
1341 return (int)(short)LOWORD(hr);
1342}
1343
1345{
1346 WCHAR szTarget[MAX_PATH], szPath[MAX_PATH];
1347 if (!SHGetPathFromIDListW(pidlTarget, szTarget))
1348 return FALSE;
1350 if (lstrcmpiW(szTarget, szPath) == 0)
1351 return TRUE;
1353 return (lstrcmpiW(szTarget, szPath) == 0);
1354}
1355
1357{
1358 HRESULT hr;
1359
1360 CComPtr<IEnumIDList> eidl;
1361 hr = m_shellFolder->EnumObjects(GetToolbar(), SHCONTF_FOLDERS | SHCONTF_NONFOLDERS, &eidl);
1363 return hr;
1364
1365 HDPA dpaSort = DPA_Create(10);
1366
1368 hr = eidl->Next(1, &item, NULL);
1369 while (hr == S_OK)
1370 {
1371 if (m_menuBand->_CallCBWithItemPidl(item, 0x10000000, 0, 0) == S_FALSE)
1372 {
1373 DPA_AppendPtr(dpaSort, item);
1374 }
1375 else
1376 {
1378 }
1379
1380 hr = eidl->Next(1, &item, NULL);
1381 }
1382
1383 // If no items were added, show the "empty" placeholder
1384 if (DPA_GetPtrCount(dpaSort) == 0)
1385 {
1386 DPA_Destroy(dpaSort);
1387 return AddPlaceholder();
1388 }
1389
1390 TRACE("FillToolbar added %d items to the DPA\n", DPA_GetPtrCount(dpaSort));
1391
1393
1394 BOOL StartMenuAdminTools = SHRegGetBoolUSValueW(
1395 L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
1396 L"StartMenuAdminTools", FALSE, TRUE);
1397
1398 BOOL bMustHideAdminTools = IsPidlPrograms(m_idList) && !StartMenuAdminTools;
1399 TRACE("StartMenuAdminTools: %d\n", StartMenuAdminTools);
1400 TRACE("bMustHideAdminTools: %d\n", bMustHideAdminTools);
1401
1402 WCHAR szAdminTools[MAX_PATH];
1403 if (bMustHideAdminTools)
1404 {
1406 szAdminTools, _countof(szAdminTools));
1407 }
1408
1409 for (int i = 0; i<DPA_GetPtrCount(dpaSort);)
1410 {
1411 item = (LPITEMIDLIST)DPA_GetPtr(dpaSort, i);
1412
1413 STRRET sr = { STRRET_CSTR };
1414 hr = m_shellFolder->GetDisplayNameOf(item, SIGDN_NORMALDISPLAY, &sr);
1416 {
1417 DPA_Destroy(dpaSort);
1418 return hr;
1419 }
1420
1421 PWSTR MenuString;
1422 StrRetToStr(&sr, NULL, &MenuString);
1423
1424 if (bMustHideAdminTools && lstrcmpiW(MenuString, szAdminTools) == 0)
1425 {
1426 ++i;
1427 CoTaskMemFree(MenuString);
1428 continue;
1429 }
1430
1432 BOOL isPureFolder = GetFolderItemBaseType(m_shellFolder, item) == SFGAO_FOLDER; // Don't expand .cab/.zip
1433
1434 // Fetch next item already, so we know if the current one is the last
1435 i++;
1436
1437 AddButton(i, MenuString, isPureFolder, index, reinterpret_cast<DWORD_PTR>(item), i >= DPA_GetPtrCount(dpaSort));
1438
1439 CoTaskMemFree(MenuString);
1440 }
1441
1442 DPA_Destroy(dpaSort);
1443 return hr;
1444}
1445
1447{
1448 //ITEMIDLIST * pidl = reinterpret_cast<LPITEMIDLIST>(dwData);
1450 return E_NOTIMPL;
1451}
1452
1454{
1455 ILFree(reinterpret_cast<LPITEMIDLIST>(tb->tbButton.dwData));
1456 return S_OK;
1457}
1458
1460{
1461 m_shellFolder = psf;
1462 m_idList = ILClone(pidlFolder);
1463 m_hKey = hKey;
1465
1466 if (IsWindow())
1467 ClearToolbar();
1468
1469 return S_OK;
1470}
1471
1473{
1474 HRESULT hr;
1475
1476 hr = m_shellFolder->QueryInterface(riid, ppv);
1478 return hr;
1479
1480 if (pdwFlags)
1481 *pdwFlags = m_dwMenuFlags;
1482
1483 if (ppidl)
1484 {
1485 LPITEMIDLIST pidl = NULL;
1486
1487 if (m_idList)
1488 {
1489 pidl = ILClone(m_idList);
1490 if (!pidl)
1491 {
1492 ERR("ILClone failed!\n");
1493 (*reinterpret_cast<IUnknown**>(ppv))->Release();
1494 return E_FAIL;
1495 }
1496 }
1497
1498 *ppidl = pidl;
1499 }
1500
1501 return hr;
1502}
1503
1505{
1506 HRESULT hr;
1507 CComPtr<IContextMenu> contextMenu = NULL;
1508 LPCITEMIDLIST pidl = reinterpret_cast<LPCITEMIDLIST>(dwData);
1509
1510 hr = m_shellFolder->GetUIObjectOf(GetToolbar(), 1, &pidl, IID_NULL_PPV_ARG(IContextMenu, &contextMenu));
1512 {
1513 return hr;
1514 }
1515
1516 hr = TrackContextMenu(contextMenu, pt);
1517
1518 return hr;
1519}
1520
1522{
1523 return m_menuBand->_CallCBWithItemPidl(reinterpret_cast<LPITEMIDLIST>(data), SMC_SFEXEC, 0, 0);
1524}
1525
1527{
1528 HRESULT hr;
1529 UINT uId;
1530 UINT uIdAncestor;
1531 DWORD flags;
1532 CComPtr<IShellMenuCallback> psmc;
1533 CComPtr<IShellMenu> shellMenu;
1534
1535 LPITEMIDLIST pidl = reinterpret_cast<LPITEMIDLIST>(dwData);
1536
1537 if (!pidl)
1538 return E_FAIL;
1539
1542 return hr;
1543
1544 m_menuBand->GetMenuInfo(&psmc, &uId, &uIdAncestor, &flags);
1545
1546 // FIXME: not sure what to use as uId/uIdAncestor here
1547 hr = shellMenu->Initialize(psmc, 0, uId, SMINIT_VERTICAL);
1549 return hr;
1550
1551 CComPtr<IShellFolder> childFolder;
1552 hr = m_shellFolder->BindToObject(pidl, NULL, IID_PPV_ARG(IShellFolder, &childFolder));
1554 return hr;
1555
1556 hr = shellMenu->SetShellFolder(childFolder, NULL, NULL, SMSET_TOP);
1558 return hr;
1559
1560 return PopupSubMenu(iItem, index, shellMenu, keyInitiated);
1561}
1562
1564{
1565 LPCITEMIDLIST pidl = reinterpret_cast<LPITEMIDLIST>(dwData);
1566 BOOL isPureFolder = GetFolderItemBaseType(m_shellFolder, pidl) == SFGAO_FOLDER;
1567 return isPureFolder ? S_OK : S_FALSE;
1568}
#define IDS_MENU_EMPTY
int CALLBACK PidlListSort(void *item1, void *item2, LPARAM lParam)
static BOOL IsPidlPrograms(LPCITEMIDLIST pidlTarget)
static SFGAOF GetFolderItemBaseType(UINT sfgao)
#define TIMERID_HOTTRACK
#define WM_USER_CHANGETRACKEDITEM
Definition: CMenuToolbars.h:26
#define IID_PPV_ARG(Itype, ppType)
HWND hWnd
Definition: settings.c:17
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define index(s, c)
Definition: various.h:29
#define ERR(fmt,...)
Definition: precomp.h:57
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
HRESULT _CallCBWithItemPidl(LPITEMIDLIST pidl, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: CMenuBand.cpp:775
HRESULT _OnPopupSubMenu(IShellMenu *childShellMenu, POINTL *pAt, RECTL *pExclude, BOOL mouseInitiated)
Definition: CMenuBand.cpp:1066
HRESULT _GetTopLevelWindow(HWND *topLevel)
Definition: CMenuBand.cpp:885
HRESULT _TrackContextMenu(IContextMenu *popup, INT x, INT y)
Definition: CMenuBand.cpp:823
HRESULT _TrackSubMenu(HMENU popup, INT x, INT y, RECT &rcExclude)
Definition: CMenuBand.cpp:802
BOOL UseBigIcons()
Definition: CMenuBand.h:207
HRESULT _KillPopupTimers()
Definition: CMenuBand.cpp:1130
HRESULT _MenuItemSelect(DWORD changeType)
Definition: CMenuBand.cpp:965
HRESULT _CancelCurrentPopup()
Definition: CMenuBand.cpp:1049
HRESULT _CallCBWithItemId(UINT Id, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: CMenuBand.cpp:770
HRESULT _ChangeHotItem(CMenuToolbarBase *tb, INT id, DWORD dwFlags)
Definition: CMenuBand.cpp:891
HRESULT AdjustForTheme(BOOL bFlatStyle)
Definition: CMenuBand.cpp:1167
HRESULT _ChangePopupItem(CMenuToolbarBase *tb, INT id)
Definition: CMenuBand.cpp:910
STDMETHOD() GetMenuInfo(IShellMenuCallback **ppsmc, UINT *puId, UINT *puIdAncestor, DWORD *pdwFlags) override
Definition: CMenuBand.cpp:91
virtual HRESULT InternalGetTooltip(INT iItem, INT index, DWORD_PTR dwData, LPWSTR pszText, INT cchTextMax) override
virtual HRESULT InternalPopupItem(INT iItem, INT index, DWORD_PTR dwData, BOOL keyInitiated) override
virtual HRESULT InternalContextMenu(INT iItem, INT index, DWORD_PTR dwData, POINT pt) override
HRESULT SetShellFolder(IShellFolder *psf, LPCITEMIDLIST pidlFolder, HKEY hKey, DWORD dwFlags)
virtual HRESULT FillToolbar(BOOL clearFirst=FALSE) override
HRESULT GetShellFolder(DWORD *pdwFlags, LPITEMIDLIST *ppidl, REFIID riid, void **ppv)
virtual ~CMenuSFToolbar()
virtual HRESULT OnDeletingButton(const NMTOOLBAR *tb) override
virtual HRESULT InternalHasSubMenu(INT iItem, INT index, DWORD_PTR dwData) override
CMenuSFToolbar(CMenuBand *menuBand)
LPCITEMIDLIST m_idList
virtual HRESULT InternalExecuteItem(INT iItem, INT index, DWORD_PTR dwData) override
CComPtr< IShellFolder > m_shellFolder
CMenuStaticToolbar(CMenuBand *menuBand)
virtual HRESULT InternalExecuteItem(INT iItem, INT index, DWORD_PTR dwData) override
HRESULT GetMenu(HMENU *phmenu, HWND *phwnd, DWORD *pdwFlags)
virtual HRESULT OnDeletingButton(const NMTOOLBAR *tb) override
virtual HRESULT InternalGetTooltip(INT iItem, INT index, DWORD_PTR dwData, LPWSTR pszText, INT cchTextMax) override
HRESULT SetMenu(HMENU hmenu, HWND hwnd, DWORD dwFlags)
virtual ~CMenuStaticToolbar()
virtual HRESULT InternalContextMenu(INT iItem, INT index, DWORD_PTR dwData, POINT pt) override
virtual HRESULT InternalPopupItem(INT iItem, INT index, DWORD_PTR dwData, BOOL keyInitiated) override
virtual HRESULT FillToolbar(BOOL clearFirst=FALSE) override
virtual HRESULT InternalHasSubMenu(INT iItem, INT index, DWORD_PTR dwData) override
HRESULT PopupSubMenu(UINT itemId, UINT index, IShellMenu *childShellMenu, BOOL keyInitiated)
HRESULT UpdateImageLists()
HRESULT GetSizes(SIZE *pMinSize, SIZE *pMaxSize, SIZE *pIntegralSize)
LRESULT ChangeTrackedItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
DWORD_PTR m_executeData
Definition: CMenuToolbars.h:55
HRESULT PopupItem(INT iItem, BOOL keyInitiated)
HRESULT AddPlaceholder()
LRESULT OnWinEventWrap(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
HRESULT KillPopupTimer()
HRESULT ProcessContextMenu(INT iItem)
CContainedWindow m_pager
Definition: CMenuToolbars.h:31
HRESULT OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *theResult)
virtual HRESULT InternalGetTooltip(INT iItem, INT index, DWORD_PTR dwData, LPWSTR pszText, INT cchTextMax) PURE
CMenuToolbarBase * m_popupBar
Definition: CMenuToolbars.h:47
virtual HRESULT OnDeletingButton(const NMTOOLBAR *tb) PURE
HRESULT CancelCurrentPopup()
LRESULT IsTrackedItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
HRESULT KeyboardItemChange(DWORD changeType)
CMenuToolbarBase(CMenuBand *menuBand, BOOL usePager)
HRESULT IsWindowOwner(HWND hwnd)
HRESULT OnCustomDraw(LPNMTBCUSTOMDRAW cdraw, LRESULT *theResult)
HRESULT ChangePopupItem(CMenuToolbarBase *toolbar, INT item)
HRESULT OnGetInfoTip(NMTBGETINFOTIP *tip)
HRESULT DisableMouseTrack(BOOL bDisable)
virtual ~CMenuToolbarBase()
HRESULT PrepareExecuteItem(INT iItem)
HRESULT MenuBarMouseUp(INT iIndex, BOOL isLButton)
HRESULT ShowDW(BOOL fShow)
HRESULT TrackContextMenu(IContextMenu *contextMenu, POINT pt)
HRESULT CreateToolbar(HWND hwndParent, DWORD dwFlags)
HRESULT ProcessClick(INT iItem)
virtual HRESULT InternalExecuteItem(INT iItem, INT index, DWORD_PTR dwData) PURE
HRESULT MenuBarMouseDown(INT iIndex, BOOL isLButton)
HRESULT GetDataFromId(INT iItem, INT *pIndex, DWORD_PTR *pData)
HRESULT SetPosSize(int x, int y, int cx, int cy)
HRESULT OnPopupTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
HRESULT ChangeHotItem(CMenuToolbarBase *toolbar, INT item, DWORD dwFlags)
HRESULT OnPagerCalcSize(LPNMPGCALCSIZE csize)
virtual HRESULT InternalPopupItem(INT iItem, INT index, DWORD_PTR dwData, BOOL keyInitiated) PURE
virtual HRESULT InternalHasSubMenu(INT iItem, INT index, DWORD_PTR dwData) PURE
HRESULT GetWindow(HWND *phwnd)
CMenuToolbarBase * m_hotBar
Definition: CMenuToolbars.h:45
CMenuBand * m_menuBand
Definition: CMenuToolbars.h:39
HRESULT BeforeCancelPopup()
HRESULT AddSeparator(BOOL last)
HRESULT AddButton(DWORD commandId, LPCWSTR caption, BOOL hasSubMenu, INT iconId, DWORD_PTR buttonData, BOOL last)
virtual HRESULT InternalContextMenu(INT iItem, INT index, DWORD_PTR dwData, POINT pt) PURE
HWND Create(HWND hWndParent, DWORD dwStyles=0, DWORD dwExStyles=0)
Definition: rosctrls.h:261
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
static HWND hwndParent
Definition: cryptui.c:299
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int idx
Definition: utils.c:40
void WINAPI CoTaskMemFree(void *ptr)
Definition: malloc.c:389
BOOL WINAPI DPA_Sort(HDPA hdpa, PFNDPACOMPARE pfnCompare, LPARAM lParam)
Definition: dpa.c:813
BOOL WINAPI DPA_Destroy(HDPA hdpa)
Definition: dpa.c:396
HDPA WINAPI DPA_Create(INT nGrow)
Definition: dpa.c:950
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
#define CALLBACK
Definition: compat.h:35
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4171
BOOL WINAPI SHRegGetBoolUSValueW(const WCHAR *subkey, const WCHAR *value, BOOL ignore_hkcu, BOOL default_value)
Definition: registry.c:4139
const WCHAR * text
Definition: package.c:1826
BOOL WINAPI SHGetSpecialFolderPathW(HWND hwndOwner, LPWSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:4394
#define FAILED_UNEXPECTEDLY
Definition: utils.cpp:33
BOOL WINAPI IsAppThemed(void)
Definition: system.c:620
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
#define pt(x, y)
Definition: drawing.c:79
#define L(x)
Definition: resources.c:13
static IShellFolder IShellItem **static IBindCtx LPITEMIDLIST SFGAOF
Definition: ebrowser.c:83
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
pKey DeleteObject()
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLuint res
Definition: glext.h:9613
GLsizeiptr size
Definition: glext.h:5919
GLuint index
Definition: glext.h:6031
GLbitfield flags
Definition: glext.h:7161
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLuint64EXT * result
Definition: glext.h:11304
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int UINT
Definition: sysinfo.c:13
int WINAPI SHMapPIDLToSystemImageListIndex(IShellFolder *sh, LPCITEMIDLIST pidl, int *pIndex)
Definition: iconcache.cpp:772
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
HRESULT CompareIDs([in] LPARAM lParam, [in] PCUIDLIST_RELATIVE pidl1, [in] PCUIDLIST_RELATIVE pidl2)
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
char hdr[14]
Definition: iptest.cpp:33
LONG_PTR LPARAM
Definition: minwindef.h:175
LONG_PTR LRESULT
Definition: minwindef.h:176
UINT_PTR WPARAM
Definition: minwindef.h:174
LPCWSTR szPath
Definition: env.c:37
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
static const LARGE_INTEGER *static const HANDLE const LARGE_INTEGER *static PSLIST_ENTRY PSLIST_ENTRY last
Definition: sync.c:64
static const WCHAR tb[]
Definition: suminfo.c:431
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define menu
Definition: input.c:3282
static HMENU hmenu
Definition: win.c:78
static const struct metadata_item item1[]
Definition: metadata.c:3603
static const struct metadata_item item2[]
Definition: metadata.c:3608
static VOID SetImageList(HWND hwnd)
Definition: mplay32.c:238
_Out_ PULONG _Out_ PULONG pIndex
Definition: ndis.h:4565
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
#define _Out_opt_
Definition: no_sal2.h:214
static HANDLE ULONG_PTR dwData
Definition: pipe.c:111
#define LOWORD(l)
Definition: pedump.c:82
#define WS_CHILD
Definition: pedump.c:617
short WCHAR
Definition: pedump.c:58
#define WS_VISIBLE
Definition: pedump.c:620
long LONG
Definition: pedump.c:60
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define WS_CLIPCHILDREN
Definition: pedump.c:619
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:238
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:1051
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1496
#define INT
Definition: polytest.cpp:20
#define NM_RELEASEDCAPTURE
Definition: commctrl.h:141
#define CDDS_ITEMPOSTPAINT
Definition: commctrl.h:286
#define RBN_CHILDSIZE
Definition: commctrl.h:1636
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
#define PGS_VERT
Definition: commctrl.h:4507
#define HICF_MOUSE
Definition: commctrl.h:1326
#define TBN_ENDDRAG
Definition: commctrl.h:1308
#define BTNS_AUTOSIZE
Definition: commctrl.h:1004
#define CDDS_ITEMPREPAINT
Definition: commctrl.h:285
#define NM_LDOWN
Definition: commctrl.h:145
#define TBSTYLE_TOOLTIPS
Definition: commctrl.h:989
#define WC_PAGESCROLLER
Definition: commctrl.h:4505
#define TBBUTTONINFO
Definition: commctrl.h:1254
#define NMTBGETINFOTIP
Definition: commctrl.h:1393
#define BTNS_SEP
Definition: commctrl.h:999
#define TBCDRF_NOEDGES
Definition: commctrl.h:1033
#define CDRF_NOTIFYITEMDRAW
Definition: commctrl.h:275
#define TBN_HOTITEMCHANGE
Definition: commctrl.h:1336
#define TBIF_LPARAM
Definition: commctrl.h:1223
#define TBSTYLE_LIST
Definition: commctrl.h:993
#define TBCDRF_NOOFFSET
Definition: commctrl.h:1035
#define PGM_SETCHILD
Definition: commctrl.h:4521
_Out_opt_ int * cx
Definition: commctrl.h:585
#define NM_TOOLTIPSCREATED
Definition: commctrl.h:144
#define CDRF_NOTIFYPOSTPAINT
Definition: commctrl.h:274
#define TTN_GETDISPINFO
Definition: commctrl.h:1883
#define TBIF_STYLE
Definition: commctrl.h:1222
#define NM_CLICK
Definition: commctrl.h:130
#define LPNMTOOLBAR
Definition: commctrl.h:1457
#define PGN_CALCSIZE
Definition: commctrl.h:4585
#define CCS_VERT
Definition: commctrl.h:2254
#define NM_CUSTOMDRAW
Definition: commctrl.h:137
#define NMTOOLBAR
Definition: commctrl.h:1456
#define TBSTYLE_EX_DOUBLEBUFFER
Definition: commctrl.h:1014
#define TBCDRF_NOBACKGROUND
Definition: commctrl.h:1040
#define TBSTYLE_TRANSPARENT
Definition: commctrl.h:996
#define CDIS_CHECKED
Definition: commctrl.h:294
#define CCS_NODIVIDER
Definition: commctrl.h:2253
#define TBN_GETDISPINFO
Definition: commctrl.h:1420
#define CCS_TOP
Definition: commctrl.h:2247
#define TBSTYLE_REGISTERDROP
Definition: commctrl.h:995
#define TBSTATE_ENABLED
Definition: commctrl.h:974
#define CDDS_PREPAINT
Definition: commctrl.h:280
#define TBSTYLE_FLAT
Definition: commctrl.h:992
#define TBN_DRAGOUT
Definition: commctrl.h:1337
#define TBN_GETINFOTIP
Definition: commctrl.h:1392
#define BTNS_DROPDOWN
Definition: commctrl.h:1003
#define TBN_BEGINDRAG
Definition: commctrl.h:1307
#define DPA_AppendPtr(hdpa, pitem)
Definition: commctrl.h:4975
#define CCS_NOPARENTALIGN
Definition: commctrl.h:2251
#define DPA_GetPtrCount(hdpa)
Definition: commctrl.h:4972
#define CCS_NORESIZE
Definition: commctrl.h:2250
#define PGF_CALCWIDTH
Definition: commctrl.h:4587
#define TBSTYLE_CUSTOMERASE
Definition: commctrl.h:994
#define TBSTATE_WRAP
Definition: commctrl.h:977
#define TBSTYLE_EX_VERTICAL
Definition: commctrl.h:1011
#define BTNS_CHECKGROUP
Definition: commctrl.h:1002
#define PGF_CALCHEIGHT
Definition: commctrl.h:4588
#define CDIS_HOT
Definition: commctrl.h:297
#define LPNMTBGETINFOTIP
Definition: commctrl.h:1394
#define TBN_DROPDOWN
Definition: commctrl.h:1316
#define TBIF_COMMAND
Definition: commctrl.h:1224
#define TBN_DELETINGBUTTON
Definition: commctrl.h:1338
#define NM_RDOWN
Definition: commctrl.h:146
#define TBCDRF_NOMARK
Definition: commctrl.h:1036
#define REFIID
Definition: guiddef.h:118
#define StrRetToStr
Definition: shlwapi.h:1252
#define CreateWindowEx
Definition: winuser.h:5921
DWORD WINAPI GetSysColor(_In_ int)
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define SW_HIDE
Definition: winuser.h:779
#define MIIM_STRING
Definition: winuser.h:738
#define MIIM_ID
Definition: winuser.h:733
#define COLOR_MENU
Definition: winuser.h:928
#define MAKELPARAM(l, h)
Definition: winuser.h:4116
#define COLOR_GRAYTEXT
Definition: winuser.h:943
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
DWORD WINAPI GetMessagePos(void)
Definition: message.c:1351
HWND WINAPI GetForegroundWindow(void)
Definition: ntwrapper.h:392
int WINAPI GetMenuItemCount(_In_opt_ HMENU)
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
HWND WINAPI SetParent(_In_ HWND, _In_opt_ HWND)
#define COLOR_HIGHLIGHT
Definition: winuser.h:937
HBRUSH WINAPI GetSysColorBrush(_In_ int)
#define WM_CANCELMODE
Definition: winuser.h:1663
#define DT_SINGLELINE
Definition: winuser.h:540
#define WM_COMMAND
Definition: winuser.h:1768
#define WM_WININICHANGE
Definition: winuser.h:1658
#define MIIM_FTYPE
Definition: winuser.h:740
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
#define VK_UP
Definition: winuser.h:2261
#define DT_NOCLIP
Definition: winuser.h:536
#define MFT_SEPARATOR
Definition: winuser.h:755
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define MIIM_SUBMENU
Definition: winuser.h:734
#define VK_END
Definition: winuser.h:2258
#define VK_HOME
Definition: winuser.h:2259
#define MFT_BITMAP
Definition: winuser.h:749
#define COLOR_HIGHLIGHTTEXT
Definition: winuser.h:938
#define DT_VCENTER
Definition: winuser.h:543
BOOL WINAPI GetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _Inout_ LPMENUITEMINFOW)
#define VK_DOWN
Definition: winuser.h:2263
#define SW_SHOW
Definition: winuser.h:786
#define DT_RIGHT
Definition: winuser.h:538
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define COLOR_MENUTEXT
Definition: winuser.h:931
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define SystemParametersInfo
Definition: winuser.h:6024
BOOL WINAPI DestroyWindow(_In_ HWND)
#define DrawTextEx
Definition: winuser.h:5938
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_NOTIFY
Definition: richedit.h:61
#define LoadStringW
Definition: utils.h:64
#define SHIL_SMALL
Definition: shellapi.h:186
#define SHIL_LARGE
Definition: shellapi.h:185
#define CMenuBand_CreateInstance
Definition: shellmenu.h:80
HRESULT WINAPI SHGetImageList(int iImageList, REFIID riid, void **ppv)
Definition: shellord.c:2890
static SFGAOF SHELL_GetAttributesOf(IShellFolder *psf, LPCITEMIDLIST pidlChild, SFGAOF query)
Definition: shellutils.h:780
#define CSIDL_COMMON_PROGRAMS
Definition: shlobj.h:2242
#define CSIDL_PROGRAMS
Definition: shlobj.h:2222
@ SMIM_ICON
Definition: shobjidl.idl:2844
@ SMIM_FLAGS
Definition: shobjidl.idl:2843
@ SMIF_TRACKPOPUP
Definition: shobjidl.idl:2863
struct tagSMINFO SMINFO
#define IDS_ADMINISTRATIVETOOLS
Definition: shresdef.h:276
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
@ STRRET_CSTR
Definition: shtypes.idl:87
const ITEMIDLIST_RELATIVE UNALIGNED * PCUIDLIST_RELATIVE
Definition: shtypes.idl:57
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
#define _countof(array)
Definition: sndvol32.h:70
#define TRACE(s)
Definition: solgame.cpp:4
DWORD dwFlag
Definition: commctrl.h:4592
Definition: dcommon.idl:28
long bottom
Definition: dcommon.idl:29
long right
Definition: dcommon.idl:29
long left
Definition: dcommon.idl:29
long top
Definition: dcommon.idl:29
Definition: dpa.c:49
NMCUSTOMDRAW nmcd
Definition: commctrl.h:1017
COLORREF clrText
Definition: commctrl.h:1021
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
BYTE fsState
Definition: commctrl.h:951
INT_PTR iString
Definition: commctrl.h:959
int idCommand
Definition: commctrl.h:950
DWORD_PTR dwData
Definition: commctrl.h:958
int iBitmap
Definition: commctrl.h:949
BYTE fsStyle
Definition: commctrl.h:952
DWORD_PTR dwItemSpec
Definition: commctrl.h:307
DWORD dwMask
Definition: shobjidl.idl:2825
DWORD dwFlags
Definition: shobjidl.idl:2827
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
uint16_t * PWSTR
Definition: typedefs.h:56
int32_t INT_PTR
Definition: typedefs.h:64
const uint16_t * LPCWSTR
Definition: typedefs.h:57
uint32_t DWORD_PTR
Definition: typedefs.h:65
uint16_t * LPWSTR
Definition: typedefs.h:56
int32_t INT
Definition: typedefs.h:58
#define HIWORD(l)
Definition: typedefs.h:247
#define SMC_EXEC
Definition: undocshell.h:872
HRESULT WINAPI SetWindowTheme(_In_ HWND hwnd, _In_ LPCWSTR pszSubAppName, _In_ LPCWSTR pszSubIdList)
Definition: uxthemesupp.c:69
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define GetModuleHandle
Definition: winbase.h:3550
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
DWORD COLORREF
Definition: windef.h:100
#define SubclassWindow(hwnd, lpfn)
Definition: windowsx.h:542
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:300
#define GET_X_LPARAM(lp)
Definition: windowsx.h:299
#define DPA_GetPtr
Definition: commctrl.h:5
#define S_FALSE
Definition: winerror.h:3451
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210
#define DEFAULT_QUALITY
Definition: wingdi.h:436
#define FF_DONTCARE
Definition: wingdi.h:448
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
#define DEFAULT_CHARSET
Definition: wingdi.h:384
#define TRANSPARENT
Definition: wingdi.h:950
#define OUT_DEFAULT_PRECIS
Definition: wingdi.h:415
#define CreateFont
Definition: wingdi.h:4889
#define CLIP_DEFAULT_PRECIS
Definition: wingdi.h:426
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:917
#define IID_NULL_PPV_ARG(Itype, ppType)