Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1342 lines
42 KiB

  1. #include "priv.h"
  2. #include "sccls.h"
  3. #include "legacy.h"
  4. #include "itbar.h"
  5. #include "itbdrop.h"
  6. #include "brand.h"
  7. #include "theater.h"
  8. #include "resource.h"
  9. #include <tb_ids.h>
  10. #include "mluisupp.h"
  11. typedef struct {
  12. HPALETTE hpal;
  13. HBITMAP hbm;
  14. int cyBrand;
  15. int cxBrandExtent;
  16. int cyBrandExtent;
  17. int cyBrandLeadIn;
  18. COLORREF clrBkStat;
  19. COLORREF clrBkAnim;
  20. LPTSTR pszBitmap;
  21. LPTSTR pszStaticBitmap;
  22. } BRANDCONTEXT;
  23. class CBrandBand : public CToolBand,
  24. public IWinEventHandler,
  25. public IDispatch
  26. {
  27. public:
  28. // IUnknown
  29. virtual STDMETHODIMP_(ULONG) AddRef(void) { return CToolBand::AddRef(); }
  30. virtual STDMETHODIMP_(ULONG) Release(void) { return CToolBand::Release(); }
  31. virtual STDMETHODIMP QueryInterface(REFIID riid, LPVOID * ppvObj);
  32. // IObjectWithSite
  33. virtual STDMETHODIMP SetSite(IUnknown* punkSite);
  34. // *** IDeskBand methods ***
  35. virtual STDMETHODIMP GetBandInfo(DWORD dwBandID, DWORD fViewMode, DESKBANDINFO* pdbi);
  36. // IOleCommandTarget
  37. virtual STDMETHODIMP Exec(const GUID *pguidCmdGroup,
  38. DWORD nCmdID, DWORD nCmdexecopt, VARIANTARG *pvarargIn,
  39. VARIANTARG *pvarargOut);
  40. // IPersist
  41. virtual STDMETHODIMP GetClassID(CLSID *pClassID);
  42. // IPersistStream
  43. virtual STDMETHODIMP Load(IStream *pStm);
  44. virtual STDMETHODIMP Save(IStream *pStm, BOOL fClearDirty);
  45. // IWinEventHandler
  46. virtual STDMETHODIMP OnWinEvent(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT* plre);
  47. virtual STDMETHODIMP IsWindowOwner(HWND hwnd);
  48. // IDispatch
  49. virtual STDMETHODIMP GetTypeInfoCount(UINT *pctinfo){return(E_NOTIMPL);}
  50. virtual STDMETHODIMP GetTypeInfo(UINT itinfo,LCID lcid,ITypeInfo **pptinfo){return(E_NOTIMPL);}
  51. virtual STDMETHODIMP GetIDsOfNames(REFIID riid,OLECHAR **rgszNames,UINT cNames, LCID lcid, DISPID * rgdispid){return(E_NOTIMPL);}
  52. virtual STDMETHODIMP Invoke(DISPID dispidMember,REFIID riid,LCID lcid,WORD wFlags,
  53. DISPPARAMS * pdispparams, VARIANT * pvarResult, EXCEPINFO * pexcepinfo,UINT * puArgErr);
  54. // IServiceProvider
  55. virtual STDMETHODIMP QueryService(REFGUID guidService, REFIID riid, void ** ppvObj);
  56. protected:
  57. CBrandBand();
  58. virtual ~CBrandBand();
  59. friend HRESULT CBrandBand_CreateInstance(IUnknown *punkOuter, IUnknown **ppunk, LPCOBJECTINFO poi); // for ctor
  60. BITBOOL _fVertical:1;
  61. BITBOOL _fAnimating:1;
  62. BITBOOL _fMinAlways:1;
  63. BITBOOL _fTheater :1;
  64. BOOL _fShellView;
  65. BRANDCONTEXT *_pbc;
  66. int _yOrg;
  67. static HDC s_hdc;
  68. static BRANDCONTEXT s_bcWebSmall; // BrandContext for the small web view bitmap
  69. static BRANDCONTEXT s_bcWebLarge; // BrandContext for the large web view bitmap
  70. static BRANDCONTEXT s_bcWebMicro; // BrandContext for the micro web view bitmap
  71. static BRANDCONTEXT s_bcShellSmall; // BrandContext for the small shell view bitmap
  72. static BRANDCONTEXT s_bcShellLarge; // BrandContext for the large shell view bitmap
  73. IWebBrowserApp * _pdie; // Used when Navigating a Browser Window with a URL String
  74. IBrowserService * _pbs; // Only valid when we are in a Browser Windows Toolbar. (Not Toolband)
  75. IWebBrowser2 * _pwb2; // Only valid when we are a Toolband (not toolbar).
  76. DWORD _dwcpCookie; // ConnectionPoint cookie for DWebBrowserEvents from the Browser Window.
  77. DWORD _dwCookieServiceBrandBand; // Service cookie for SID_SBrandBand
  78. LONG _lAnimateCount; // Keep track of how many StartAnimation/StopAnimation were requested
  79. // Helper functions
  80. void _UpdateCompressedSize();
  81. HRESULT _CreateBrandBand();
  82. HRESULT _LoadBrandingBitmap();
  83. void _DrawBranding(HDC hdc);
  84. int _GetLinksExtent();
  85. void _OnTimer(WPARAM id);
  86. void _StartAnimation();
  87. void _StopAnimation();
  88. static void _InitGlobals();
  89. static void _InitBrandContexts();
  90. static void _InitBrandContext(BRANDCONTEXT* pbc, LPCTSTR pszBrandLeadIn, LPCTSTR pszBrandHeight,
  91. LPCTSTR pszBrandBitmap, LPCTSTR pszBitmap, int idBrandBitmap);
  92. HRESULT _ConnectToBrwsrWnd(IUnknown* punk);
  93. HRESULT _ConnectToBrwsrConnectionPoint(BOOL fConnect);
  94. static LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  95. friend void CBrandBand_CleanUp();
  96. friend void Brand_InitBrandContexts();
  97. static void _GetBrandContextHeight(BRANDCONTEXT* pbc, LPCTSTR pszBrandLeadIn, LPCTSTR pszBrandHeight,
  98. LPCTSTR pszBrandBitmap, LPCTSTR pszBitmap, int idBrandBitmap);
  99. private:
  100. };
  101. #define SUPERCLASS CToolBand
  102. #define BM_BANDINFOCHANGED (WM_USER + 1)
  103. #ifdef DEBUG
  104. extern unsigned long DbStreamTell(IStream *pstm);
  105. #else
  106. #define DbStreamTell(pstm) ((ULONG) 0)
  107. #endif
  108. extern HRESULT VariantClearLazy(VARIANTARG *pvarg);
  109. #define ANIMATION_TIMER 5678
  110. #define MICROBITMAPID() (IDB_IEMICROBRAND)
  111. #define SMALLBITMAPID() (IDB_IESMBRAND)
  112. #define LARGEBITMAPID() (IDB_IEBRAND)
  113. BRANDCONTEXT CBrandBand::s_bcWebMicro = {NULL}; // BrandContext for the micro web view bitmap
  114. BRANDCONTEXT CBrandBand::s_bcWebSmall = {NULL}; // BrandContext for the small web view bitmap
  115. BRANDCONTEXT CBrandBand::s_bcWebLarge = {NULL}; // BrandContext for the large web view bitmap
  116. BRANDCONTEXT CBrandBand::s_bcShellSmall = {NULL}; // BrandContext for the small shell view bitmap
  117. BRANDCONTEXT CBrandBand::s_bcShellLarge = {NULL}; // BrandContext for the large shell view bitmap
  118. // The heights of the bitmaps (each frame!) stored is this module's resources
  119. // ** NOTE **
  120. // If you change the animated brands that are stored in browseui:
  121. // MAKE SURE THESE HEIGHTS are correct!!
  122. // ** - dsheldon - **
  123. #define BRANDHEIGHT_WEBLARGE 38
  124. #define BRANDHEIGHT_WEBSMALL 26
  125. #define BRANDHEIGHT_WEBMICRO 22
  126. HDC CBrandBand::s_hdc = NULL;
  127. BOOL g_fUseMicroBrand = TRUE;
  128. UINT g_cySmBrand = 0;
  129. static const TCHAR szRegKeyIE20[] = TEXT("SOFTWARE\\Microsoft\\Internet Explorer\\Main");
  130. static const TCHAR szValueLargeBitmap[] = TEXT("BigBitmap");
  131. static const TCHAR szValueSmallBitmap[] = TEXT("SmallBitmap");
  132. static const TCHAR szValueBrandBitmap[] = TEXT("BrandBitmap");
  133. static const TCHAR szValueBrandHeight[] = TEXT("BrandHeight");
  134. static const TCHAR szValueBrandLeadIn[] = TEXT("BrandLeadIn");
  135. static const TCHAR szValueSmBrandBitmap[] = TEXT("SmBrandBitmap");
  136. static const TCHAR szValueSmBrandHeight[] = TEXT("SmBrandHeight");
  137. static const TCHAR szValueSmBrandLeadIn[] = TEXT("SmBrandLeadIn");
  138. static const TCHAR szValueSHLargeBitmap[] = TEXT("SHBigBitmap");
  139. static const TCHAR szValueSHSmallBitmap[] = TEXT("SHSmallBitmap");
  140. static const TCHAR szValueSHBrandBitmap[] = TEXT("SHBrandBitmap");
  141. static const TCHAR szValueSHBrandHeight[] = TEXT("SHBrandHeight");
  142. static const TCHAR szValueSHBrandLeadIn[] = TEXT("SHBrandLeadIn");
  143. static const TCHAR szValueSHSmBrandBitmap[] = TEXT("SHSmBrandBitmap");
  144. static const TCHAR szValueSHSmBrandHeight[] = TEXT("SHSmBrandHeight");
  145. static const TCHAR szValueSHSmBrandLeadIn[] = TEXT("SHSmBrandLeadIn");
  146. static const TCHAR szRegKeyCoolbar[] = TEXT("Software\\Microsoft\\Internet Explorer\\Toolbar");
  147. // NOTE: szRegKeyCoolbar is duplicated from itbar.cpp!
  148. void CBrandBand_CleanUp()
  149. {
  150. if (CBrandBand::s_hdc)
  151. {
  152. HDC hdcT;
  153. HBITMAP hbmT, * pbmp = NULL;
  154. // pick out any old bitmap to flush dc with
  155. if (CBrandBand::s_bcWebLarge.hbm)
  156. pbmp = &CBrandBand::s_bcWebLarge.hbm;
  157. else if (CBrandBand::s_bcWebSmall.hbm)
  158. pbmp = &CBrandBand::s_bcWebSmall.hbm;
  159. // We need to get rid of the branding bitmap from the s_hdc
  160. // before we delete it else we leak. Do this the hard way since
  161. // we don't have a stock bitmap available to us.
  162. if (pbmp)
  163. {
  164. hdcT = CreateCompatibleDC(NULL);
  165. if (hdcT)
  166. {
  167. hbmT = (HBITMAP)SelectObject(hdcT, *pbmp);
  168. SelectObject(CBrandBand::s_hdc, hbmT);
  169. SelectObject(hdcT, hbmT);
  170. DeleteDC(hdcT);
  171. }
  172. }
  173. DeleteDC(CBrandBand::s_hdc);
  174. }
  175. // no palette to delete as we use the global one..
  176. // delete the shared palette
  177. if (CBrandBand::s_bcWebSmall.hbm)
  178. DeleteObject(CBrandBand::s_bcWebSmall.hbm);
  179. if (CBrandBand::s_bcWebLarge.hbm)
  180. DeleteObject(CBrandBand::s_bcWebLarge.hbm);
  181. if (!g_fUseMicroBrand) {
  182. if (CBrandBand::s_bcShellSmall.hbm)
  183. DeleteObject(CBrandBand::s_bcShellSmall.hbm);
  184. if (CBrandBand::s_bcShellLarge.hbm)
  185. DeleteObject(CBrandBand::s_bcShellLarge.hbm);
  186. } else {
  187. if (CBrandBand::s_bcWebMicro.hbm)
  188. DeleteObject(CBrandBand::s_bcWebMicro.hbm);
  189. }
  190. }
  191. /////////////////////////////////////////////////////////////////////////////
  192. // CBrandBand
  193. /////////////////////////////////////////////////////////////////////////////
  194. HRESULT CBrandBand_CreateInstance( IUnknown *punkOuter, IUnknown **ppunk, LPCOBJECTINFO poi)
  195. {
  196. // Aggregation checking is handled in class factory
  197. HRESULT hr;
  198. *ppunk = NULL;
  199. CBrandBand * p = new CBrandBand();
  200. if (p != NULL)
  201. {
  202. *ppunk = SAFECAST(p, IDeskBand *);
  203. hr = S_OK;
  204. }
  205. else
  206. {
  207. hr = E_OUTOFMEMORY;
  208. }
  209. return hr;
  210. }
  211. CBrandBand::CBrandBand() : SUPERCLASS()
  212. {
  213. ASSERT(_fAnimating == FALSE);
  214. ASSERT(_hwnd == NULL);
  215. _pbc = &s_bcShellLarge;
  216. }
  217. CBrandBand::~CBrandBand()
  218. {
  219. ASSERT(!_pdie || !_pwb2 || !_pbs);
  220. if (IsWindow(_hwnd))
  221. {
  222. DestroyWindow(_hwnd);
  223. }
  224. }
  225. // IUnknown::QueryInterface
  226. HRESULT CBrandBand::QueryInterface(REFIID riid, void **ppvObj)
  227. {
  228. if (IsEqualIID(riid, IID_IWinEventHandler))
  229. {
  230. *ppvObj = SAFECAST(this, IWinEventHandler*);
  231. }
  232. else if (IsEqualIID(riid, IID_IPersistStream))
  233. {
  234. *ppvObj = SAFECAST(this, IPersistStream*);
  235. }
  236. else if (IsEqualIID(riid, IID_IDispatch))
  237. {
  238. *ppvObj = SAFECAST(this, IDispatch*);
  239. }
  240. else
  241. {
  242. return SUPERCLASS::QueryInterface(riid, ppvObj);
  243. }
  244. AddRef();
  245. return S_OK;
  246. }
  247. // IDockingWindow::SetSite
  248. HRESULT CBrandBand::SetSite(IUnknown * punkSite)
  249. {
  250. if (_pdie || _pwb2 || _pbs)
  251. _ConnectToBrwsrWnd(NULL); // On-connect from Browser Window.
  252. // Make sure we proffer the service only once
  253. // This is important since we get created multiple times,
  254. IUnknown *punk = NULL;
  255. // Check if we need to revoke our service, or if our service was already proffered by
  256. // another instance of CBrandBand
  257. if ((!punkSite && _dwCookieServiceBrandBand) ||
  258. (punkSite && FAILED(IUnknown_QueryService(punkSite, SID_SBrandBand, IID_IUnknown, (void **)&punk))))
  259. {
  260. // Proffer or Revoke BrandBand service as appropriate
  261. IUnknown_ProfferService(punkSite ? punkSite : _punkSite,
  262. SID_SBrandBand,
  263. punkSite ? SAFECAST(this, IServiceProvider *) : NULL,
  264. &_dwCookieServiceBrandBand);
  265. // Failure here does not require special handling
  266. }
  267. ATOMICRELEASE(punk);
  268. SUPERCLASS::SetSite(punkSite);
  269. if (punkSite)
  270. {
  271. _CreateBrandBand();
  272. // This call will fail if the host doesn't have a Browser Window.
  273. _ConnectToBrwsrWnd(punkSite);
  274. }
  275. return S_OK;
  276. }
  277. // IDeskBand::GetBandInfo
  278. HRESULT CBrandBand::GetBandInfo(DWORD dwBandID, DWORD fViewMode, DESKBANDINFO* pdbi)
  279. {
  280. _dwBandID = dwBandID;
  281. _fVertical = ((fViewMode & DBIF_VIEWMODE_VERTICAL) != 0);
  282. _LoadBrandingBitmap();
  283. pdbi->dwModeFlags = DBIMF_FIXEDBMP;
  284. if (!_fMinAlways)
  285. pdbi->dwModeFlags |= DBIMF_VARIABLEHEIGHT;
  286. int cxWidth = _fTheater ? CX_FLOATERSHOWN : _GetLinksExtent();
  287. pdbi->ptMinSize.x = max(s_bcWebSmall.cxBrandExtent, max(s_bcShellSmall.cxBrandExtent, cxWidth));
  288. pdbi->ptMaxSize.x = max(s_bcWebLarge.cxBrandExtent, max(s_bcShellLarge.cxBrandExtent, cxWidth));
  289. pdbi->ptMaxSize.y = max(s_bcWebLarge.cyBrand, s_bcShellLarge.cyBrand);
  290. if (g_fUseMicroBrand)
  291. pdbi->ptMinSize.y = s_bcWebMicro.cyBrand;
  292. else
  293. pdbi->ptMinSize.y = max(s_bcWebSmall.cyBrand, s_bcShellSmall.cyBrand);
  294. pdbi->ptIntegral.y = -1;
  295. return S_OK;
  296. }
  297. // IWinEventHandler::OnWinEvent
  298. HRESULT CBrandBand::OnWinEvent(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *plres)
  299. {
  300. *plres = 0;
  301. switch (uMsg)
  302. {
  303. case WM_WININICHANGE:
  304. if (SHIsExplorerIniChange(wParam, lParam))
  305. {
  306. _InitBrandContexts();
  307. InvalidateRect(_hwnd, NULL, TRUE);
  308. }
  309. *plres = SendMessage(_hwnd, uMsg, wParam, lParam);
  310. break;
  311. }
  312. return S_OK;
  313. }
  314. // IWinEventHandler::IsWindowOwner
  315. HRESULT CBrandBand::IsWindowOwner(HWND hwnd)
  316. {
  317. if (hwnd == _hwnd)
  318. return S_OK;
  319. return S_FALSE;
  320. }
  321. // IPersistStream::GetClassID
  322. HRESULT CBrandBand::GetClassID(CLSID * pClassID)
  323. {
  324. *pClassID = CLSID_BrandBand;
  325. return S_OK;
  326. }
  327. // IPersistStream::Load
  328. HRESULT CBrandBand::Load(IStream *pstm)
  329. {
  330. return S_OK;
  331. }
  332. // IPersistStream::Load
  333. HRESULT CBrandBand::Save(IStream *pstm, BOOL fClearDirty)
  334. {
  335. return S_OK;
  336. }
  337. #define ANIMATION_PERIOD 30
  338. #define ANIMATION_PERIOD_FAST 15
  339. // IDispatch::Invoke
  340. HRESULT CBrandBand::Invoke
  341. (
  342. DISPID dispidMember,
  343. REFIID riid,
  344. LCID lcid,
  345. WORD wFlags,
  346. DISPPARAMS * pdispparams,
  347. VARIANT * pvarResult,
  348. EXCEPINFO * pexcepinfo,
  349. UINT * puArgErr
  350. )
  351. {
  352. ASSERT(pdispparams);
  353. if (!pdispparams)
  354. return E_INVALIDARG;
  355. switch (dispidMember)
  356. {
  357. case DISPID_DOWNLOADBEGIN:
  358. {
  359. _StartAnimation();
  360. break;
  361. }
  362. case DISPID_DOWNLOADCOMPLETE:
  363. {
  364. _StopAnimation();
  365. break;
  366. }
  367. default:
  368. return E_INVALIDARG;
  369. }
  370. return S_OK;
  371. }
  372. void CBrandBand::_InitGlobals()
  373. {
  374. if (!s_hdc) {
  375. ENTERCRITICAL;
  376. if (!s_hdc)
  377. {
  378. s_hdc = CreateCompatibleDC(NULL);
  379. if (s_hdc && GetDeviceCaps(s_hdc, RASTERCAPS) & RC_PALETTE)
  380. {
  381. // share the global palette ....
  382. ASSERT( g_hpalHalftone );
  383. s_bcWebMicro.hpal = g_hpalHalftone;
  384. s_bcWebSmall.hpal = s_bcShellSmall.hpal = g_hpalHalftone;
  385. s_bcWebLarge.hpal = s_bcShellLarge.hpal = g_hpalHalftone;
  386. }
  387. }
  388. LEAVECRITICAL;
  389. }
  390. }
  391. HRESULT CBrandBand::_CreateBrandBand()
  392. {
  393. HRESULT hr;
  394. ASSERT(_hwndParent); // Call us after SetSite()
  395. if (!_hwndParent)
  396. {
  397. // The caller hasn't called SetSite(), so we can't
  398. // create our window because we can't find out our parent's
  399. // HWND.
  400. return E_FAIL;
  401. }
  402. // create branding window
  403. _hwnd = SHCreateWorkerWindow(WndProc, _hwndParent, 0, WS_CHILD, NULL, this);
  404. if (_hwnd)
  405. {
  406. _InitGlobals();
  407. hr = S_OK;
  408. }
  409. else
  410. {
  411. hr = E_OUTOFMEMORY;
  412. TraceMsg(TF_ERROR, "CBrandBand::_CreateBrandBand() - Could not create Brand Band!");
  413. }
  414. return hr;
  415. }
  416. void Brand_InitBrandContexts()
  417. {
  418. CBrandBand::_InitGlobals();
  419. CBrandBand::_InitBrandContexts();
  420. }
  421. void CBrandBand::_InitBrandContexts()
  422. {
  423. // note: these calls set g_fUseMicroBrand
  424. _GetBrandContextHeight(&s_bcWebSmall, szValueSmBrandLeadIn, szValueSmBrandHeight,
  425. szValueSmBrandBitmap, szValueSmallBitmap, SMALLBITMAPID());
  426. _GetBrandContextHeight(&s_bcWebLarge, szValueBrandLeadIn, szValueBrandHeight,
  427. szValueBrandBitmap, szValueLargeBitmap, LARGEBITMAPID());
  428. // if no third party brands found
  429. if (g_fUseMicroBrand) {
  430. // init micro brand
  431. _GetBrandContextHeight(&s_bcWebMicro, NULL, NULL,
  432. NULL, NULL, MICROBITMAPID());
  433. } else {
  434. // init shell brands
  435. _GetBrandContextHeight(&s_bcShellSmall, szValueSHSmBrandLeadIn, szValueSHSmBrandHeight,
  436. szValueSHSmBrandBitmap, szValueSHSmallBitmap, SMALLBITMAPID());
  437. _GetBrandContextHeight(&s_bcShellLarge, szValueSHBrandLeadIn, szValueSHBrandHeight,
  438. szValueSHBrandBitmap, szValueSHLargeBitmap, LARGEBITMAPID());
  439. }
  440. }
  441. /****************************************************************************
  442. CBrandBand::_GetBrandContextHeight
  443. Sets the cyBrand member of the supplied brand context. This function
  444. uses the height information stored in the registry if it is available.
  445. If an alternate source for bitmaps is found and the height information
  446. is available in the registry, it is assumed we will not be using our
  447. micro brand (g_fUseMicroBrand = FALSE).
  448. Otherwise, it is assumed that no custom bitmaps are available and
  449. the cyBrand will be set to constant values representing the height
  450. of our standard branding.
  451. Note that if it appears that there are custom bitmaps available but the
  452. height cannot be read, we will attempt to read the custom bitmaps and
  453. determine the height that way (by delegating to _InitBrandContext)
  454. ****************************************************************************/
  455. void CBrandBand::_GetBrandContextHeight(BRANDCONTEXT* pbc, LPCTSTR pszBrandLeadIn, LPCTSTR pszBrandHeight,
  456. LPCTSTR pszBrandBitmap, LPCTSTR pszBitmap, int idBrandBitmap)
  457. {
  458. HKEY hKey;
  459. DWORD cbData;
  460. DWORD dwType;
  461. BOOL fThirdPartyBitmap = FALSE;
  462. TCHAR szScratch[MAX_PATH];
  463. szScratch[0] = 0;
  464. // try to determine if there is a third party bitmap available for the specified
  465. // brand... Check if the anitmated bitmap exists
  466. if (pszBrandBitmap && ERROR_SUCCESS == RegOpenKeyEx(HKEY_CURRENT_USER, szRegKeyCoolbar, 0, KEY_QUERY_VALUE, &hKey))
  467. {
  468. // See if an alternate file was specified for the animated bmp
  469. cbData = sizeof(szScratch);
  470. if ((ERROR_SUCCESS == SHQueryValueEx(hKey, pszBrandBitmap, NULL, &dwType,
  471. (LPBYTE)szScratch, &cbData)))
  472. {
  473. if (szScratch[0] != 0)
  474. fThirdPartyBitmap = TRUE;
  475. }
  476. // It appears there are third party bitmaps
  477. // try to find the height of the animated bitmap
  478. if (pszBrandHeight && fThirdPartyBitmap)
  479. {
  480. cbData = sizeof(pbc->cyBrand);
  481. if (ERROR_SUCCESS == SHQueryValueEx(hKey, pszBrandHeight, NULL, &dwType,
  482. (LPBYTE)&pbc->cyBrand, &cbData))
  483. {
  484. // Third party brands probably exist
  485. g_fUseMicroBrand = FALSE;
  486. }
  487. else
  488. {
  489. // In this case, we know there should be 3rd party bitmaps but no
  490. // height was specified in the registry. We have to bite the bullet
  491. // and load the bitmaps now: Delegate to _InitBrandContext()
  492. _InitBrandContext(pbc, pszBrandLeadIn, pszBrandHeight,
  493. pszBrandBitmap, pszBitmap, idBrandBitmap);
  494. }
  495. }
  496. RegCloseKey(hKey);
  497. }
  498. if (!fThirdPartyBitmap && pszBitmap &&
  499. ERROR_SUCCESS == RegOpenKeyEx(HKEY_CURRENT_USER, szRegKeyCoolbar, 0, KEY_QUERY_VALUE, &hKey))
  500. {
  501. // See if an alternate file was specified for the static bmp
  502. cbData = sizeof(szScratch);
  503. if ((ERROR_SUCCESS == SHQueryValueEx(hKey, pszBitmap, NULL, &dwType,
  504. (LPBYTE)szScratch, &cbData)))
  505. {
  506. if (szScratch[0] != 0)
  507. {
  508. // In this case, we know there is a 3rd party static bitmap but no
  509. // animated bitmap was specified in the registry. We have to bite the bullet
  510. // and load the bitmaps now: Delegate to _InitBrandContext()
  511. fThirdPartyBitmap = TRUE;
  512. _InitBrandContext(pbc, pszBrandLeadIn, pszBrandHeight,
  513. pszBrandBitmap, pszBitmap, idBrandBitmap);
  514. }
  515. }
  516. RegCloseKey(hKey);
  517. }
  518. // If we didn't find any third party bitmaps, we need to set it the height
  519. // to the size of the bitmaps in this module's resources
  520. if (!fThirdPartyBitmap)
  521. {
  522. // Set the height based on which bitmap ID is requested
  523. switch (idBrandBitmap)
  524. {
  525. case IDB_IEMICROBRAND:
  526. pbc->cyBrand = BRANDHEIGHT_WEBMICRO;
  527. break;
  528. case IDB_IESMBRAND:
  529. pbc->cyBrand = BRANDHEIGHT_WEBSMALL;
  530. break;
  531. case IDB_IEBRAND:
  532. pbc->cyBrand = BRANDHEIGHT_WEBLARGE;
  533. break;
  534. default:
  535. // bad ID passed in!
  536. ASSERT(FALSE);
  537. }
  538. }
  539. }
  540. void CBrandBand::_InitBrandContext(BRANDCONTEXT* pbc, LPCTSTR pszBrandLeadIn, LPCTSTR pszBrandHeight,
  541. LPCTSTR pszBrandBitmap, LPCTSTR pszBitmap, int idBrandBitmap)
  542. {
  543. ENTERCRITICAL;
  544. HKEY hKey = NULL;
  545. DWORD dwType = 0;
  546. TCHAR szScratch[MAX_PATH];
  547. DWORD dwcbData;
  548. BOOL fBitmapInvalid = !pbc->hbm;
  549. LPTSTR pszNewBitmap = NULL;
  550. LPTSTR pszOldBitmap = pbc->pszBitmap;
  551. HBITMAP hbmp = NULL;
  552. BOOL fExternalAnimatedBitmap = FALSE;
  553. BOOL fUseWindowsXPBranding = FALSE;
  554. // process animated brand bitmap
  555. // see if the location spec for the bitmap has been changed
  556. if (pszBrandBitmap && ERROR_SUCCESS == RegOpenKeyEx(HKEY_CURRENT_USER, szRegKeyCoolbar, 0, KEY_QUERY_VALUE, &hKey))
  557. {
  558. dwcbData = SIZEOF(szScratch);
  559. if ((ERROR_SUCCESS == SHQueryValueEx(hKey, pszBrandBitmap, NULL, &dwType,
  560. (LPBYTE)szScratch, &dwcbData)))
  561. {
  562. pszNewBitmap = szScratch;
  563. fExternalAnimatedBitmap = TRUE;
  564. }
  565. }
  566. if (!(pszNewBitmap == pszOldBitmap || (pszNewBitmap && pszOldBitmap && !lstrcmpi(pszNewBitmap, pszOldBitmap))))
  567. fBitmapInvalid = TRUE;
  568. if (fBitmapInvalid) {
  569. Str_SetPtr(&pbc->pszBitmap, pszNewBitmap);
  570. if (pszNewBitmap) {
  571. if (pszNewBitmap[0]) { // not empty string
  572. hbmp = (HBITMAP) LoadImage(NULL, szScratch, IMAGE_BITMAP, 0, 0,
  573. LR_DEFAULTSIZE | LR_CREATEDIBSECTION | LR_LOADFROMFILE);
  574. }
  575. }
  576. if (!hbmp)
  577. {
  578. if (hKey != NULL)
  579. {
  580. RegCloseKey(hKey);
  581. hKey = NULL;
  582. }
  583. HINSTANCE hInstDll = HINST_THISDLL;
  584. INT iBitmapID = idBrandBitmap;
  585. if (GetUIVersion() > 5)
  586. {
  587. BOOL bHighColor = (SHGetCurColorRes() > 8) ? TRUE : FALSE;
  588. if (idBrandBitmap == MICROBITMAPID())
  589. {
  590. if (bHighColor)
  591. iBitmapID = IDB_BRAND_BITMAP_MICRO;
  592. else
  593. iBitmapID = IDB_BRAND256_BITMAP_MICRO;
  594. fUseWindowsXPBranding = TRUE;
  595. }
  596. else if (idBrandBitmap == SMALLBITMAPID())
  597. {
  598. if (bHighColor)
  599. iBitmapID = IDB_BRAND_BITMAP_SMALL;
  600. else
  601. iBitmapID = IDB_BRAND256_BITMAP_SMALL;
  602. fUseWindowsXPBranding = TRUE;
  603. }
  604. else if (idBrandBitmap == LARGEBITMAPID())
  605. {
  606. if (bHighColor)
  607. iBitmapID = IDB_BRAND_BITMAP_LARGE;
  608. else
  609. iBitmapID = IDB_BRAND256_BITMAP_LARGE;
  610. fUseWindowsXPBranding = TRUE;
  611. }
  612. if (fUseWindowsXPBranding)
  613. {
  614. hInstDll = GetModuleHandle (TEXT("shell32.dll"));
  615. }
  616. }
  617. hbmp = (HBITMAP) LoadImage(hInstDll, MAKEINTRESOURCE(iBitmapID), IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE | LR_CREATEDIBSECTION);
  618. } else
  619. g_fUseMicroBrand = FALSE;
  620. if (!hbmp) goto ErrorDone;
  621. if (pbc->hbm) DeleteObject(pbc->hbm);
  622. pbc->hbm = hbmp;
  623. // set the background to be the first pixel
  624. SelectObject(s_hdc, pbc->hbm);
  625. pbc->clrBkAnim = GetPixel(s_hdc, 0, 0);
  626. if (fUseWindowsXPBranding)
  627. {
  628. pbc->clrBkStat = pbc->clrBkAnim;
  629. }
  630. DIBSECTION dib;
  631. GetObject(pbc->hbm, sizeof(DIBSECTION), &dib);
  632. pbc->cxBrandExtent = dib.dsBm.bmWidth;
  633. pbc->cyBrandExtent = dib.dsBm.bmHeight;
  634. dwcbData = sizeof(DWORD);
  635. // APPCOMPAT:: hkey is not setup when the second instance calls in
  636. if (!hKey || (ERROR_SUCCESS != SHQueryValueEx(hKey, pszBrandHeight, NULL, &dwType,
  637. (LPBYTE)&pbc->cyBrand, &dwcbData)))
  638. pbc->cyBrand = pbc->cxBrandExtent;
  639. #define EXTERNAL_IMAGE_OFFSET 4
  640. #define INTERNAL_IMAGE_OFFSET 0
  641. if (!hKey || (ERROR_SUCCESS != SHQueryValueEx(hKey, pszBrandLeadIn, NULL, &dwType,
  642. (LPBYTE)&pbc->cyBrandLeadIn, &dwcbData)))
  643. {
  644. #ifndef UNIX
  645. if (fExternalAnimatedBitmap)
  646. // use old 4-image offset for back compat
  647. pbc->cyBrandLeadIn = EXTERNAL_IMAGE_OFFSET;
  648. else
  649. pbc->cyBrandLeadIn = INTERNAL_IMAGE_OFFSET;
  650. #else
  651. // IEUNIX : We use a different branding bitmap.
  652. pbc->cyBrandLeadIn = EXTERNAL_IMAGE_OFFSET;
  653. #endif
  654. }
  655. pbc->cyBrandLeadIn *= pbc->cyBrand;
  656. }
  657. if (hKey)
  658. RegCloseKey(hKey);
  659. // process the static bitmap
  660. pszNewBitmap = NULL;
  661. pszOldBitmap = pbc->pszStaticBitmap;
  662. hbmp = NULL;
  663. // see if the location spec for the bitmap has been changed
  664. dwcbData = SIZEOF(szScratch);
  665. if (ERROR_SUCCESS == SHGetValue(HKEY_CURRENT_USER, szRegKeyCoolbar, pszBitmap, &dwType, szScratch, &dwcbData))
  666. {
  667. pszNewBitmap = szScratch;
  668. }
  669. if (!(pszNewBitmap == pszOldBitmap || (pszNewBitmap && pszOldBitmap && !lstrcmpi(pszNewBitmap, pszOldBitmap))))
  670. fBitmapInvalid = TRUE;
  671. if (fBitmapInvalid) {
  672. Str_SetPtr(&pbc->pszStaticBitmap, pszNewBitmap);
  673. if (pszNewBitmap) {
  674. if (pszNewBitmap[0]) { // not empty string
  675. hbmp = (HBITMAP) LoadImage(NULL, szScratch, IMAGE_BITMAP, 0, 0,
  676. LR_DEFAULTSIZE | LR_CREATEDIBSECTION | LR_LOADFROMFILE);
  677. }
  678. }
  679. if (hbmp) {
  680. DIBSECTION dib;
  681. HDC hdcOld = CreateCompatibleDC(s_hdc);
  682. if (hdcOld)
  683. {
  684. SelectObject(s_hdc, pbc->hbm);
  685. GetObject(hbmp, sizeof(DIBSECTION), &dib);
  686. SelectObject(hdcOld, hbmp);
  687. // Set background to color of first pixel
  688. pbc->clrBkStat = GetPixel(hdcOld, 0, 0);
  689. StretchBlt(s_hdc, 0, 0, pbc->cxBrandExtent, pbc->cyBrand, hdcOld, 0, 0,
  690. dib.dsBm.bmWidth, dib.dsBm.bmHeight, SRCCOPY);
  691. DeleteDC(hdcOld);
  692. }
  693. DeleteObject(hbmp);
  694. // If there was a custom brand, we can't use our micro brand
  695. g_fUseMicroBrand = FALSE;
  696. }
  697. if (pbc == &s_bcShellSmall)
  698. g_cySmBrand = pbc->cyBrand;
  699. }
  700. ErrorDone:
  701. LEAVECRITICAL;
  702. }
  703. void CBrandBand::_UpdateCompressedSize()
  704. {
  705. RECT rc;
  706. BOOL fCompressed = FALSE;
  707. BRANDCONTEXT *pbcOld = _pbc;
  708. GetClientRect(_hwnd, &rc);
  709. if (RECTHEIGHT(rc) < max(s_bcWebLarge.cyBrand, s_bcShellLarge.cyBrand)) {
  710. if (g_fUseMicroBrand && RECTHEIGHT(rc) < s_bcWebSmall.cyBrand)
  711. {
  712. if (s_bcWebMicro.hbm == NULL)
  713. {
  714. _InitBrandContext(&s_bcWebMicro, NULL, NULL,
  715. NULL, NULL, MICROBITMAPID());
  716. }
  717. _pbc = &s_bcWebMicro;
  718. }
  719. else
  720. {
  721. if (_fShellView)
  722. {
  723. if (s_bcShellSmall.hbm == NULL)
  724. {
  725. if (g_fUseMicroBrand)
  726. {
  727. // In this case, the shell and web bitmaps are always the same;
  728. // load the web bitmap and use it for the shell also
  729. if (s_bcWebSmall.hbm == NULL)
  730. {
  731. _InitBrandContext(&s_bcWebSmall, szValueSmBrandLeadIn, szValueSmBrandHeight,
  732. szValueSmBrandBitmap, szValueSmallBitmap, SMALLBITMAPID());
  733. }
  734. s_bcShellSmall = s_bcWebSmall;
  735. }
  736. else
  737. {
  738. // We have different web and shell bitmaps; load the shell one
  739. _InitBrandContext(&s_bcShellSmall, szValueSHSmBrandLeadIn, szValueSHSmBrandHeight,
  740. szValueSHSmBrandBitmap, szValueSHSmallBitmap, SMALLBITMAPID());
  741. }
  742. }
  743. _pbc = &s_bcShellSmall;
  744. }
  745. else
  746. {
  747. // We are in web view mode
  748. if (s_bcWebSmall.hbm == NULL)
  749. {
  750. _InitBrandContext(&s_bcWebSmall, szValueSmBrandLeadIn, szValueSmBrandHeight,
  751. szValueSmBrandBitmap, szValueSmallBitmap, SMALLBITMAPID());
  752. }
  753. _pbc = &s_bcWebSmall;
  754. }
  755. }
  756. }
  757. else
  758. {
  759. if (_fShellView)
  760. {
  761. if (s_bcShellLarge.hbm == NULL)
  762. {
  763. if (g_fUseMicroBrand)
  764. {
  765. // Shell and Web bitmaps are the same. Load the web one and copy it
  766. if (s_bcWebLarge.hbm == NULL)
  767. {
  768. _InitBrandContext(&s_bcWebLarge, szValueBrandLeadIn, szValueBrandHeight,
  769. szValueBrandBitmap, szValueLargeBitmap, LARGEBITMAPID());
  770. }
  771. s_bcShellLarge = s_bcWebLarge;
  772. }
  773. else
  774. {
  775. // Need to load the shell bitmap separately
  776. _InitBrandContext(&s_bcShellLarge, szValueSHBrandLeadIn, szValueSHBrandHeight,
  777. szValueSHBrandBitmap, szValueSHLargeBitmap, LARGEBITMAPID());
  778. }
  779. }
  780. _pbc = &s_bcShellLarge;
  781. }
  782. else
  783. {
  784. // We're in web view
  785. if (s_bcWebLarge.hbm == NULL)
  786. {
  787. _InitBrandContext(&s_bcWebLarge, szValueBrandLeadIn, szValueBrandHeight,
  788. szValueBrandBitmap, szValueLargeBitmap, LARGEBITMAPID());
  789. }
  790. _pbc = &s_bcWebLarge;
  791. }
  792. }
  793. if (_pbc != pbcOld) {
  794. MSG msg;
  795. _yOrg = 0;
  796. InvalidateRect(_hwnd, NULL, TRUE);
  797. if (!PeekMessage(&msg, _hwnd, BM_BANDINFOCHANGED, BM_BANDINFOCHANGED, PM_NOREMOVE))
  798. PostMessage(_hwnd, BM_BANDINFOCHANGED, 0, 0);
  799. }
  800. }
  801. HRESULT CBrandBand::_LoadBrandingBitmap()
  802. {
  803. if (_pbc->hbm)
  804. return S_OK; // Nothing to do, already loaded.
  805. _yOrg = 0;
  806. _InitBrandContexts();
  807. return(S_OK);
  808. }
  809. void CBrandBand::_DrawBranding(HDC hdc)
  810. {
  811. HPALETTE hpalPrev;
  812. RECT rcPaint;
  813. COLORREF clrBk = _fAnimating? _pbc->clrBkAnim : _pbc->clrBkStat;
  814. int x, y, cx, cy;
  815. int yOrg = 0;
  816. DWORD dwRop = SRCCOPY;
  817. if (_fAnimating)
  818. yOrg = _yOrg;
  819. if (_pbc->hpal)
  820. {
  821. // select in our palette so the branding will get mapped to
  822. // whatever the current system palette is. Note we do not
  823. // pass FALSE, so we will no actually select this palette into
  824. // system palette FG. Otherwise the branding will flash the
  825. // palette
  826. hpalPrev = SelectPalette(hdc, _pbc->hpal, TRUE);
  827. RealizePalette(hdc);
  828. }
  829. GetClientRect(_hwnd, &rcPaint);
  830. x = rcPaint.left;
  831. cx = RECTWIDTH(rcPaint);
  832. y = rcPaint.top;
  833. cy = RECTHEIGHT(rcPaint);
  834. if (cx > _pbc->cxBrandExtent)
  835. {
  836. RECT rc = rcPaint;
  837. int dx = ((cx - _pbc->cxBrandExtent) / 2) + 1;
  838. rc.right = rc.left + dx;
  839. SHFillRectClr(hdc, &rc, clrBk);
  840. rc.right = rcPaint.right;
  841. rc.left = rc.right - dx;
  842. SHFillRectClr(hdc, &rc, clrBk);
  843. }
  844. if (cy > _pbc->cyBrand)
  845. {
  846. RECT rc = rcPaint;
  847. int dy = ((cy - _pbc->cyBrand) / 2) + 1;
  848. rc.bottom = rc.top + dy;
  849. SHFillRectClr(hdc, &rc, clrBk);
  850. rc.bottom = rcPaint.bottom;
  851. rc.top = rc.bottom - dy;
  852. SHFillRectClr(hdc, &rc, clrBk);
  853. }
  854. // center it
  855. if (cx > _pbc->cxBrandExtent)
  856. x += (cx - _pbc->cxBrandExtent) / 2;
  857. if (cy > _pbc->cyBrand)
  858. y += (cy - _pbc->cyBrand) / 2;
  859. //
  860. // To prevent the transform from flipping
  861. // calculations should be based on the bm width
  862. // when the DC is Right-To-Left mirrored and
  863. // not to flip the IE logo bitmap [samera]
  864. //
  865. if (IS_WINDOW_RTL_MIRRORED(_hwnd))
  866. {
  867. // Actual width
  868. cx = _pbc->cxBrandExtent;
  869. // Don't flip the logo here
  870. dwRop |= DONTMIRRORBITMAP;
  871. }
  872. ENTERCRITICAL;
  873. SelectObject(s_hdc, _pbc->hbm);
  874. BitBlt(hdc, x, y, cx, _pbc->cyBrand, s_hdc, 0, yOrg, dwRop);
  875. LEAVECRITICAL;
  876. if (_pbc->hpal)
  877. {
  878. // reselect in the old palette
  879. SelectPalette(hdc, hpalPrev, TRUE);
  880. RealizePalette(hdc);
  881. }
  882. }
  883. int CBrandBand::_GetLinksExtent()
  884. {
  885. return 0x26;
  886. }
  887. void CBrandBand::_OnTimer(WPARAM id)
  888. {
  889. _yOrg += _pbc->cyBrand;
  890. if (_yOrg >= _pbc->cyBrandExtent)
  891. _yOrg = _pbc->cyBrandLeadIn;
  892. RedrawWindow(_hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
  893. }
  894. void CBrandBand::_StartAnimation()
  895. {
  896. // We need to be called on the UI thread, as we are not thread-safe.
  897. ASSERT(GetWindowThreadProcessId(_hwnd, NULL) == GetCurrentThreadId());
  898. if (++_lAnimateCount == 1)
  899. {
  900. // The timer does a invalidate of _hwnd which in cases
  901. // of no toolbar showing caused the entire desktop to
  902. // repaint and repaint and...
  903. if (_hwnd)
  904. {
  905. if (GetUIVersion() > 5)
  906. SetTimer(_hwnd, ANIMATION_TIMER, ANIMATION_PERIOD, NULL);
  907. else
  908. SetTimer(_hwnd, ANIMATION_TIMER, ANIMATION_PERIOD_FAST, NULL);
  909. }
  910. _yOrg = 0;
  911. _fAnimating = TRUE;
  912. IUnknown_Exec(_punkSite, &CGID_Theater, THID_ACTIVATE, 0, NULL, NULL);
  913. }
  914. }
  915. void CBrandBand::_StopAnimation()
  916. {
  917. // We need to be called on the UI thread, as we are not thread-safe.
  918. ASSERT(GetWindowThreadProcessId(_hwnd, NULL) == GetCurrentThreadId());
  919. if (--_lAnimateCount == 0)
  920. {
  921. _fAnimating = FALSE;
  922. KillTimer(_hwnd, ANIMATION_TIMER);
  923. InvalidateRect(_hwnd, NULL, FALSE);
  924. UpdateWindow(_hwnd);
  925. IUnknown_Exec(_punkSite, &CGID_Theater, THID_DEACTIVATE, 0, NULL, NULL);
  926. }
  927. }
  928. // The IUnknown parameter needs to point to an object that supports the
  929. // IBrowserService and IWebBrowserApp interfaces.
  930. HRESULT CBrandBand::_ConnectToBrwsrWnd(IUnknown * punk)
  931. {
  932. HRESULT hr = S_OK;
  933. if (_pdie)
  934. {
  935. // Remove the tie from the AddressBand to the Browser Window
  936. _ConnectToBrwsrConnectionPoint(FALSE);
  937. ATOMICRELEASE(_pdie);
  938. }
  939. ATOMICRELEASE(_pwb2);
  940. ATOMICRELEASE(_pbs);
  941. if (punk)
  942. {
  943. // Tie the AddressBand to the Browser Window passed in.
  944. IServiceProvider* psp = NULL;
  945. hr = punk->QueryInterface(IID_IServiceProvider, (void **)&psp);
  946. if (SUCCEEDED(hr))
  947. {
  948. // NOTE: We are either a Toolbar, in which case _pbs is valid
  949. // and _pwb2 is NULL, or we are a Toolband and _pbs is
  950. // NULL and _pwb2 is valid. Both will be NULL when the
  951. // Toolband has yet to create a Browser Window.
  952. if (FAILED(psp->QueryService(SID_STopLevelBrowser, IID_IBrowserService, (void**)&_pbs)))
  953. hr = psp->QueryService(SID_SWebBrowserApp, IID_IWebBrowser2, (void**)&_pwb2);
  954. hr = psp->QueryService(SID_SWebBrowserApp, IID_IWebBrowserApp, (void**)&_pdie);
  955. psp->Release();
  956. if (_pdie && (_pwb2 || _pbs))
  957. _ConnectToBrwsrConnectionPoint(TRUE);
  958. else
  959. {
  960. ATOMICRELEASE(_pdie);
  961. ATOMICRELEASE(_pwb2);
  962. ATOMICRELEASE(_pbs);
  963. hr = E_FAIL;
  964. }
  965. }
  966. }
  967. return hr;
  968. }
  969. /////////////////////////////////////////////////////////////////////////////
  970. // Connect to Browser Window's ConnectionPoint that will provide events
  971. // to let us keep up to date.
  972. /////////////////////////////////////////////////////////////////////////////
  973. HRESULT CBrandBand::_ConnectToBrwsrConnectionPoint(BOOL fConnect)
  974. {
  975. return ConnectToConnectionPoint(SAFECAST(this, IDeskBand*),
  976. DIID_DWebBrowserEvents, fConnect, _pdie, &_dwcpCookie, NULL);
  977. }
  978. LRESULT CALLBACK CBrandBand::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  979. {
  980. CBrandBand * ptc= (CBrandBand *)GetWindowPtr0(hwnd); // GetWindowLong(hwnd, 0)
  981. switch (uMsg)
  982. {
  983. case WM_TIMER:
  984. ptc->_OnTimer(wParam);
  985. break;
  986. case WM_ERASEBKGND:
  987. {
  988. HDC hdc = (HDC)wParam;
  989. RECT rc;
  990. GetClientRect(hwnd, &rc);
  991. SHFillRectClr(hdc, &rc, ptc->_fAnimating ? ptc->_pbc->clrBkAnim : ptc->_pbc->clrBkStat);
  992. break;
  993. }
  994. case WM_PAINT:
  995. ptc->_UpdateCompressedSize();
  996. if (GetUpdateRect(hwnd, NULL, FALSE))
  997. {
  998. PAINTSTRUCT ps;
  999. BeginPaint(hwnd, &ps);
  1000. ptc->_DrawBranding(ps.hdc);
  1001. EndPaint(hwnd, &ps);
  1002. }
  1003. break;
  1004. case WM_SIZE:
  1005. InvalidateRect(ptc->_hwnd, NULL, TRUE);
  1006. ptc->_UpdateCompressedSize();
  1007. break;
  1008. case BM_BANDINFOCHANGED:
  1009. ptc->_BandInfoChanged();
  1010. break;
  1011. default:
  1012. return DefWindowProcWrap(hwnd, uMsg, wParam, lParam);
  1013. }
  1014. return 0;
  1015. }
  1016. HRESULT CBrandBand::Exec(const GUID *pguidCmdGroup,
  1017. DWORD nCmdID, DWORD nCmdexecopt, VARIANTARG *pvarargIn, VARIANTARG *pvarargOut)
  1018. {
  1019. HRESULT hr = OLECMDERR_E_UNKNOWNGROUP; // assume failure
  1020. if (pguidCmdGroup) {
  1021. if (IsEqualGUID(CGID_PrivCITCommands, *pguidCmdGroup))
  1022. {
  1023. hr = S_OK;
  1024. switch (nCmdID)
  1025. {
  1026. case CITIDM_BRANDSIZE:
  1027. if (pvarargIn && pvarargIn->vt == VT_I4) {
  1028. BOOL fMin = BOOLIFY(pvarargIn->lVal);
  1029. if (fMin != BOOLIFY(_fMinAlways)) {
  1030. _fMinAlways = fMin;
  1031. _BandInfoChanged();
  1032. }
  1033. }
  1034. break;
  1035. case CITIDM_ONINTERNET:
  1036. switch (nCmdexecopt)
  1037. {
  1038. case CITE_SHELL:
  1039. _fShellView = TRUE;
  1040. if (_pbs)
  1041. {
  1042. LPITEMIDLIST pidl;
  1043. hr = _pbs->GetPidl(&pidl);
  1044. if (SUCCEEDED(hr))
  1045. {
  1046. // We may really be an IShellView for an internet NSE (like FTP)
  1047. // Find out if they want this feature
  1048. _fShellView = !IsBrowserFrameOptionsPidlSet(pidl, BFO_USE_IE_LOGOBANDING);
  1049. ILFree(pidl);
  1050. }
  1051. }
  1052. break;
  1053. case CITE_INTERNET:
  1054. _fShellView = FALSE;
  1055. break;
  1056. }
  1057. _UpdateCompressedSize();
  1058. break;
  1059. case CITIDM_THEATER:
  1060. switch(nCmdexecopt) {
  1061. case THF_ON:
  1062. _fTheater = TRUE;
  1063. break;
  1064. case THF_OFF:
  1065. _fTheater = FALSE;
  1066. break;
  1067. default:
  1068. goto Bail;
  1069. }
  1070. _BandInfoChanged();
  1071. break;
  1072. case CITIDM_GETDEFAULTBRANDCOLOR:
  1073. if (pvarargOut && pvarargOut->vt == VT_I4)
  1074. pvarargOut->lVal = g_fUseMicroBrand ? s_bcWebSmall.clrBkStat : s_bcShellSmall.clrBkStat;
  1075. break;
  1076. }
  1077. }
  1078. else if (IsEqualGUID(CGID_BrandCmdGroup, *pguidCmdGroup))
  1079. {
  1080. hr = S_OK;
  1081. switch (nCmdID)
  1082. {
  1083. case CBRANDIDM_STARTGLOBEANIMATION:
  1084. _StartAnimation();
  1085. break;
  1086. case CBRANDIDM_STOPGLOBEANIMATION:
  1087. _StopAnimation();
  1088. break;
  1089. default:
  1090. hr = OLECMDERR_E_NOTSUPPORTED;
  1091. break;
  1092. }
  1093. }
  1094. }
  1095. Bail:
  1096. return hr;
  1097. }
  1098. // IQueryService implementation
  1099. HRESULT CBrandBand::QueryService(REFGUID guidService, REFIID riid, void ** ppvObj)
  1100. {
  1101. HRESULT hres = E_NOTIMPL;
  1102. if (IsEqualIID(guidService, SID_SBrandBand))
  1103. {
  1104. hres = QueryInterface(riid, ppvObj);
  1105. }
  1106. else
  1107. {
  1108. hres = CToolBand::QueryService(guidService, riid, ppvObj);
  1109. }
  1110. return hres;
  1111. }