4 * Copyright 2006 - 2007 Thomas Weidenmueller <w3seek@reactos.org>
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.
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.
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 Street, Fifth Floor, Boston, MA 02110-1301 USA
24 UpdateStartMenu(IN OUT IMenuPopup
*pMenuPopup
,
25 IN HBITMAP hbmBanner OPTIONAL
,
28 CComPtr
<IBanneredBar
> pbb
;
31 hRet
= pMenuPopup
->QueryInterface(IID_PPV_ARG(IBanneredBar
, &pbb
));
34 hRet
= pbb
->SetBitmap(hbmBanner
);
36 /* Update the icon size */
37 hRet
= pbb
->SetIconSize(bSmallIcons
? BMICON_SMALL
: BMICON_LARGE
);
44 CreateStartMenu(IN ITrayWindow
*Tray
,
45 OUT IMenuBand
**ppMenuBand
,
46 IN HBITMAP hbmBanner OPTIONAL
,
50 IObjectWithSite
*pOws
= NULL
;
51 IMenuPopup
*pMp
= NULL
;
52 IUnknown
*pSms
= NULL
;
53 IMenuBand
*pMb
= NULL
;
54 IInitializeObject
*pIo
;
55 IUnknown
*pUnk
= NULL
;
56 IBandSite
*pBs
= NULL
;
59 hr
= CreateStartMenuSite(Tray
, IID_PPV_ARG(IUnknown
, &pSms
));
60 if (FAILED_UNEXPECTEDLY(hr
))
64 hr
= CoCreateInstance(&CLSID_StartMenu
,
70 hr
= _CStartMenu_Constructor(IID_PPV_ARG(IMenuPopup
, &pMp
));
72 if (FAILED_UNEXPECTEDLY(hr
))
74 TRACE("CoCreateInstance failed: %x\n", hr
);
78 hr
= pMp
->QueryInterface(IID_PPV_ARG(IObjectWithSite
, &pOws
));
79 if (FAILED_UNEXPECTEDLY(hr
))
81 TRACE("IMenuPopup_QueryInterface failed: %x\n", hr
);
85 /* Set the menu site so we can handle messages */
86 hr
= pOws
->SetSite(pSms
);
87 if (FAILED_UNEXPECTEDLY(hr
))
89 TRACE("IObjectWithSite_SetSite failed: %x\n", hr
);
93 /* Initialize the menu object */
94 hr
= pMp
->QueryInterface(IID_PPV_ARG(IInitializeObject
, &pIo
));
97 hr
= pIo
->Initialize();
103 /* Everything is initialized now. Let's get the IMenuBand interface. */
104 if (FAILED_UNEXPECTEDLY(hr
))
106 TRACE("IMenuPopup_QueryInterface failed: %x\n", hr
);
110 hr
= pMp
->GetClient(&pUnk
);
111 if (FAILED_UNEXPECTEDLY(hr
))
113 TRACE("IMenuPopup_GetClient failed: %x\n", hr
);
117 hr
= pUnk
->QueryInterface(IID_PPV_ARG(IBandSite
, &pBs
));
118 if (FAILED_UNEXPECTEDLY(hr
))
120 TRACE("IUnknown_QueryInterface pBs failed: %x\n", hr
);
124 /* Finally we have the IBandSite interface, there's only one
125 band in it that apparently provides the IMenuBand interface */
126 hr
= pBs
->EnumBands(0, &dwBandId
);
127 if (FAILED_UNEXPECTEDLY(hr
))
129 TRACE("IBandSite_EnumBands failed: %x\n", hr
);
133 hr
= pBs
->GetBandObject(dwBandId
, IID_PPV_ARG(IMenuBand
, &pMb
));
134 if (FAILED_UNEXPECTEDLY(hr
))
136 TRACE("IBandSite_GetBandObject failed: %x\n", hr
);
147 else if (pMb
!= NULL
)
161 if (FAILED_UNEXPECTEDLY(hr
))