ea441036e0cab996e33b944bcc87e5b5340fa1c9
[reactos.git] / reactos / dll / win32 / shell32 / shellmenu / CBandSite.cpp
1 /*
2 * Rebar band site
3 *
4 * Copyright 2007 Hervé Poussineau
5 * Copyright 2009 Andrew Hill
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22 #include "shellmenu.h"
23 #include <shobjidl.h>
24
25 #include "CBandSite.h"
26
27 WINE_DEFAULT_DEBUG_CHANNEL(CBandSite);
28
29 #ifndef ASSERT
30 #define ASSERT(cond) \
31 if (!(cond)) \
32 ERR ("ASSERTION %s AT %s:%d FAILED!\n", #cond, __FILE__, __LINE__)
33 #endif
34
35 extern "C"
36 HRESULT WINAPI CBandSite_Constructor(REFIID riid, LPVOID *ppv)
37 {
38 return ShellObjectCreator<CBandSite>(riid, ppv);
39 }
40
41 CBandSiteBase::CBandSiteBase()
42 {
43 fBandsCount = 0;
44 fBandsAllocated = 0;
45 fBands = NULL;
46 fRebarWindow = NULL;
47 }
48
49 UINT CBandSiteBase::GetBandID(struct BandObject *Band)
50 {
51 return (UINT)(Band - fBands);
52 }
53
54 struct CBandSiteBase::BandObject *CBandSiteBase::GetBandByID(DWORD dwBandID)
55 {
56 if ((LONG)dwBandID >= fBandsAllocated)
57 return NULL;
58
59 if (fBands[dwBandID].DeskBand == NULL)
60 return NULL;
61
62 return &fBands[dwBandID];
63 }
64
65 void CBandSiteBase::FreeBand(struct BandObject *Band)
66 {
67 ATLASSERT(Band->DeskBand != NULL);
68 ATLASSERT(Band->OleWindow != NULL);
69 ATLASSERT(Band->WndEvtHandler != NULL);
70 Band->DeskBand->Release();
71 Band->OleWindow->Release();
72 Band->WndEvtHandler->Release();
73 memset(Band, 0, sizeof(*Band));
74 fBandsCount--;
75 }
76
77 DWORD CBandSiteBase::GetBandSiteViewMode()
78 {
79 DWORD dwStyle;
80
81 /* FIXME: What about DBIF_VIEWMODE_FLOATING and DBIF_VIEWMODE_TRANSPARENT? */
82 dwStyle = GetWindowLongPtr(fRebarWindow, GWL_STYLE);
83
84 if (dwStyle & CCS_VERT)
85 return DBIF_VIEWMODE_VERTICAL;
86 else
87 return DBIF_VIEWMODE_NORMAL;
88 }
89
90 VOID CBandSiteBase::BuildRebarBandInfo(struct BandObject *Band, REBARBANDINFOW *prbi)
91 {
92 ZeroMemory(prbi, sizeof(*prbi));
93 prbi->cbSize = sizeof(*prbi);
94
95 prbi->fMask = RBBIM_ID;
96 prbi->wID = GetBandID(Band);
97
98 if (Band->dbi.dwMask & DBIM_MINSIZE)
99 {
100 prbi->fMask |= RBBIM_CHILDSIZE;
101 prbi->cxMinChild = Band->dbi.ptMinSize.x;
102 prbi->cyMinChild = Band->dbi.ptMinSize.y;
103 }
104
105 if (Band->dbi.dwMask & DBIM_MAXSIZE)
106 {
107 prbi->fMask |= RBBIM_CHILDSIZE;
108 prbi->cyMaxChild = Band->dbi.ptMaxSize.y;
109 }
110
111 if ((Band->dbi.dwMask & (DBIM_INTEGRAL | DBIM_MODEFLAGS)) == (DBIM_INTEGRAL | DBIM_MODEFLAGS) &&
112 (Band->dbi.dwModeFlags & DBIMF_VARIABLEHEIGHT))
113 {
114 prbi->fMask |= RBBIM_CHILDSIZE;
115 prbi->cyIntegral = Band->dbi.ptIntegral.y;
116 }
117
118 if (Band->dbi.dwMask & DBIM_ACTUAL)
119 {
120 prbi->fMask |= RBBIM_IDEALSIZE | RBBIM_SIZE | RBBIM_CHILDSIZE;
121 prbi->cxIdeal = Band->dbi.ptActual.x;
122 prbi->cx = Band->dbi.ptActual.x;
123 prbi->cyChild = Band->dbi.ptActual.y;
124 }
125
126 if (Band->dbi.dwMask & DBIM_TITLE)
127 {
128 prbi->fMask |= RBBIM_TEXT;
129 prbi->lpText = Band->dbi.wszTitle;
130 prbi->cch = wcslen(Band->dbi.wszTitle);
131 }
132
133 if (Band->dbi.dwMask & DBIM_MODEFLAGS)
134 {
135 prbi->fMask |= RBBIM_STYLE;
136
137 if (Band->dbi.dwModeFlags & DBIMF_FIXED)
138 prbi->fStyle |= RBBS_FIXEDSIZE | RBBS_NOGRIPPER;
139 if (Band->dbi.dwModeFlags & DBIMF_FIXEDBMP)
140 prbi->fStyle |= RBBS_FIXEDBMP;
141 if (Band->dbi.dwModeFlags & DBIMF_VARIABLEHEIGHT)
142 prbi->fStyle |= RBBS_VARIABLEHEIGHT;
143 if (Band->dbi.dwModeFlags & DBIMF_DEBOSSED)
144 prbi->fStyle |= RBBS_CHILDEDGE;
145 if (Band->dbi.dwModeFlags & DBIMF_USECHEVRON)
146 prbi->fStyle |= RBBS_USECHEVRON;
147 if (Band->dbi.dwModeFlags & DBIMF_BREAK)
148 prbi->fStyle |= RBBS_BREAK;
149 if (Band->dbi.dwModeFlags & DBIMF_TOPALIGN)
150 prbi->fStyle |= RBBS_TOPALIGN;
151 if (Band->dbi.dwModeFlags & DBIMF_NOGRIPPER)
152 prbi->fStyle |= RBBS_NOGRIPPER;
153 if (Band->dbi.dwModeFlags & DBIMF_ALWAYSGRIPPER)
154 prbi->fStyle |= RBBS_GRIPPERALWAYS;
155 }
156
157 if ((Band->dbi.dwMask & (DBIM_BKCOLOR | DBIM_MODEFLAGS)) == (DBIM_BKCOLOR | DBIM_MODEFLAGS) &&
158 (Band->dbi.dwModeFlags & DBIMF_BKCOLOR))
159 {
160 prbi->fMask |= RBBIM_COLORS;
161 prbi->clrFore = (COLORREF)(COLOR_WINDOWTEXT + 1);
162 prbi->clrBack = Band->dbi.crBkgnd;
163 }
164 }
165
166 HRESULT CBandSiteBase::UpdateSingleBand(struct BandObject *Band)
167 {
168 REBARBANDINFOW rbi;
169 DWORD dwViewMode;
170 UINT uBand;
171 HRESULT hRet;
172
173 ZeroMemory(&Band->dbi, sizeof(Band->dbi));
174 Band->dbi.dwMask = DBIM_MINSIZE | DBIM_MAXSIZE | DBIM_INTEGRAL |
175 DBIM_ACTUAL | DBIM_TITLE | DBIM_MODEFLAGS | DBIM_BKCOLOR;
176
177 dwViewMode = GetBandSiteViewMode();
178
179 hRet = Band->DeskBand->GetBandInfo((DWORD)GetBandID(Band), dwViewMode, &Band->dbi);
180 if (SUCCEEDED(hRet))
181 {
182 BuildRebarBandInfo(Band, &rbi);
183 if (SUCCEEDED(Band->OleWindow->GetWindow(&rbi.hwndChild)) &&
184 rbi.hwndChild != NULL)
185 {
186 rbi.fMask |= RBBIM_CHILD;
187 WARN ("ReBar band uses child window 0x%p\n", rbi.hwndChild);
188 }
189
190 uBand = (UINT)SendMessageW(fRebarWindow, RB_IDTOINDEX, (WPARAM)rbi.wID, 0);
191 if (uBand != (UINT)-1)
192 {
193 if (!SendMessageW(fRebarWindow, RB_SETBANDINFOW, (WPARAM)uBand, reinterpret_cast<LPARAM>(&rbi)))
194 {
195 WARN("Failed to update the rebar band!\n");
196 }
197 }
198 else
199 WARN("Failed to map rebar band id to index!\n");
200
201 }
202
203 return hRet;
204 }
205
206 HRESULT CBandSiteBase::UpdateAllBands()
207 {
208 LONG i;
209 HRESULT hRet;
210
211 for (i = 0; i < fBandsAllocated; i++)
212 {
213 if (fBands[i].DeskBand != NULL)
214 {
215 hRet = UpdateSingleBand(&fBands[i]);
216 if (FAILED_UNEXPECTEDLY(hRet))
217 return hRet;
218 }
219 }
220
221 return S_OK;
222 }
223
224 HRESULT CBandSiteBase::UpdateBand(DWORD dwBandID)
225 {
226 struct BandObject *Band;
227
228 Band = GetBandByID(dwBandID);
229 if (Band == NULL)
230 return E_FAIL;
231
232 return UpdateSingleBand(Band);
233 }
234
235 struct CBandSiteBase::BandObject *CBandSiteBase::GetBandFromHwnd(HWND hwnd)
236 {
237 HRESULT hRet;
238 HWND hWndBand;
239 LONG i;
240
241 for (i = 0; i < fBandsAllocated; i++)
242 {
243 if (fBands[i].DeskBand != NULL)
244 {
245 ASSERT(fBands[i].OleWindow);
246
247 hWndBand = NULL;
248 hRet = fBands[i].OleWindow->GetWindow(&hWndBand);
249 if (SUCCEEDED(hRet) && hWndBand == hwnd)
250 return &fBands[i];
251 }
252 }
253
254 return NULL;
255 }
256
257 CBandSiteBase::~CBandSiteBase()
258 {
259
260 TRACE("destroying %p\n", this);
261
262 if (fRebarWindow != NULL)
263 {
264 DestroyWindow(fRebarWindow);
265 fRebarWindow = NULL;
266 }
267
268 if (fBands != NULL)
269 {
270 for (INT i = 0; i < fBandsAllocated; i++)
271 {
272 if (fBands[i].DeskBand != NULL)
273 FreeBand(&fBands[i]);
274 }
275 CoTaskMemFree(fBands);
276 fBands = NULL;
277 }
278 }
279
280 HRESULT STDMETHODCALLTYPE CBandSiteBase::AddBand(IUnknown *punk)
281 {
282 LONG NewAllocated;
283 struct BandObject *NewBand = NULL;
284 CComPtr<IDeskBand> DeskBand;
285 CComPtr<IObjectWithSite> ObjWithSite;
286 CComPtr<IOleWindow> OleWindow;
287 CComPtr<IWinEventHandler> WndEvtHandler;
288 REBARBANDINFOW rbi;
289 HRESULT hRet;
290 UINT uBand;
291
292 TRACE("(%p, %p)\n", this, punk);
293
294 if (punk == NULL || fRebarWindow == NULL)
295 return E_FAIL;
296
297 hRet = punk->QueryInterface(IID_PPV_ARG(IDeskBand, &DeskBand));
298 if (!SUCCEEDED(hRet) || DeskBand == NULL)
299 goto Cleanup;
300 hRet = punk->QueryInterface(IID_PPV_ARG(IObjectWithSite, &ObjWithSite));
301 if (!SUCCEEDED(hRet) || ObjWithSite == NULL)
302 goto Cleanup;
303 hRet = punk->QueryInterface(IID_PPV_ARG(IOleWindow, &OleWindow));
304 if (!SUCCEEDED(hRet) || OleWindow == NULL)
305 goto Cleanup;
306 hRet = punk->QueryInterface(IID_PPV_ARG(IWinEventHandler, &WndEvtHandler));
307 if (!SUCCEEDED(hRet) || WndEvtHandler == NULL)
308 goto Cleanup;
309
310 hRet = S_OK;
311 if (fBandsAllocated > fBandsCount)
312 {
313 /* Search for a free band object */
314 for (INT i = 0; i < fBandsAllocated; i++)
315 {
316 if (fBands[i].DeskBand == NULL)
317 {
318 NewBand = &fBands[i];
319 break;
320 }
321 }
322 }
323 else if (fBandsAllocated > 0)
324 {
325 ASSERT (fBands != NULL);
326
327 /* Reallocate the band object array */
328 NewAllocated = fBandsAllocated + 8;
329 if (NewAllocated > 0xFFFF)
330 NewAllocated = 0xFFFF;
331 if (NewAllocated == fBandsAllocated)
332 {
333 hRet = E_OUTOFMEMORY;
334 goto Cleanup;
335 }
336
337
338 NewBand = static_cast<struct BandObject *>(CoTaskMemAlloc(NewAllocated * sizeof(struct BandObject)));
339 if (NewBand == NULL)
340 {
341 hRet = E_OUTOFMEMORY;
342 goto Cleanup;
343 }
344
345 /* Copy the old array */
346 memcpy(NewBand, fBands, fBandsAllocated * sizeof(struct BandObject));
347
348 /* Initialize the added bands */
349 memset(&NewBand[fBandsAllocated], 0, (NewAllocated - fBandsAllocated) * sizeof(struct BandObject));
350
351 fBandsAllocated = NewAllocated;
352 CoTaskMemFree(fBands);
353 fBands = NewBand;
354 }
355 else
356 {
357 ASSERT(fBands == NULL);
358 ASSERT(fBandsAllocated == 0);
359 ASSERT(fBandsCount == 0);
360
361 /* Allocate new array */
362 fBands = static_cast<struct BandObject *>(CoTaskMemAlloc(8 * sizeof(struct BandObject)));
363 if (fBands == NULL)
364 {
365 hRet = E_OUTOFMEMORY;
366 goto Cleanup;
367 }
368
369 /* Initialize the added bands */
370 memset(fBands, 0, 8 * sizeof(struct BandObject));
371
372 fBandsAllocated += 8;
373 NewBand = &fBands[0];
374 }
375
376 if (SUCCEEDED(hRet))
377 {
378 ASSERT(NewBand != NULL);
379
380 fBandsCount++;
381 NewBand->DeskBand = DeskBand.Detach();
382 NewBand->OleWindow = OleWindow.Detach();
383 NewBand->WndEvtHandler = WndEvtHandler.Detach();
384
385 /* Create the ReBar band */
386 hRet = ObjWithSite->SetSite(static_cast<IOleWindow *>(this));
387 if (SUCCEEDED(hRet))
388 {
389 uBand = 0xffffffff;
390 if (SUCCEEDED(UpdateSingleBand(NewBand)))
391 {
392 if (NewBand->dbi.dwMask & DBIM_MODEFLAGS)
393 {
394 if (NewBand->dbi.dwModeFlags & DBIMF_ADDTOFRONT)
395 uBand = 0;
396 }
397 }
398
399 BuildRebarBandInfo(NewBand, &rbi);
400
401 if (SUCCEEDED(NewBand->OleWindow->GetWindow(&rbi.hwndChild)) &&
402 rbi.hwndChild != NULL)
403 {
404 rbi.fMask |= RBBIM_CHILD;
405 WARN ("ReBar band uses child window 0x%p\n", rbi.hwndChild);
406 }
407
408 if (!SendMessageW(fRebarWindow, RB_INSERTBANDW, (WPARAM)uBand, reinterpret_cast<LPARAM>(&rbi)))
409 return E_FAIL;
410
411 hRet = (HRESULT)((USHORT)GetBandID(NewBand));
412 }
413 else
414 {
415 WARN("IBandSite::AddBand(): Call to IDeskBand::SetSite() failed: %x\n", hRet);
416
417 /* Remove the band from the ReBar control */
418 BuildRebarBandInfo(NewBand, &rbi);
419 uBand = (UINT)SendMessageW(fRebarWindow, RB_IDTOINDEX, (WPARAM)rbi.wID, 0);
420 if (uBand != (UINT)-1)
421 {
422 if (!SendMessageW(fRebarWindow, RB_DELETEBAND, (WPARAM)uBand, 0))
423 {
424 ERR("Failed to delete band!\n");
425 }
426 }
427 else
428 ERR("Failed to map band id to index!\n");
429
430 FreeBand(NewBand);
431
432 hRet = E_FAIL;
433 /* goto Cleanup; */
434 }
435 }
436 Cleanup:
437 return hRet;
438 }
439
440 HRESULT STDMETHODCALLTYPE CBandSiteBase::EnumBands(UINT uBand, DWORD *pdwBandID)
441 {
442 DWORD i;
443
444 TRACE("(%p, %u, %p)\n", this, uBand, pdwBandID);
445
446 if (uBand == 0xffffffff)
447 return (UINT)fBandsCount;
448
449 if (uBand >= (UINT)fBandsCount)
450 return E_FAIL;
451
452 for (i = 0; i < (DWORD)fBandsAllocated; i++)
453 {
454 if (fBands[i].DeskBand != NULL)
455 {
456 if (uBand == 0)
457 {
458 *pdwBandID = i;
459 return S_OK;
460 }
461
462 uBand--;
463 }
464 }
465
466 return E_FAIL;
467 }
468
469 HRESULT STDMETHODCALLTYPE CBandSiteBase::QueryBand(DWORD dwBandID, IDeskBand **ppstb,
470 DWORD *pdwState, LPWSTR pszName, int cchName)
471 {
472 struct BandObject *Band;
473
474 TRACE("(%p, %u, %p, %p, %p, %d)\n", this, dwBandID, ppstb, pdwState, pszName, cchName);
475
476 Band = GetBandByID(dwBandID);
477 if (Band == NULL)
478 return E_FAIL;
479
480 if (ppstb != NULL)
481 {
482 Band->DeskBand->AddRef();
483 *ppstb = Band->DeskBand;
484 }
485
486 if (pdwState != NULL)
487 {
488 FIXME("IBandSite::QueryBand() requests band state!\n");
489 *pdwState = 0;
490 }
491
492 if (pszName != NULL && cchName > 0)
493 {
494 FIXME("IBandSite::QueryBand() requests band name!\n");
495 pszName[0] = 0;
496 }
497 return S_OK;
498 }
499
500 HRESULT STDMETHODCALLTYPE CBandSiteBase::SetBandState(DWORD dwBandID, DWORD dwMask, DWORD dwState)
501 {
502 struct BandObject *Band;
503
504 TRACE("(%p, %u, %x, %x)\n", this, dwBandID, dwMask, dwState);
505
506 Band = GetBandByID(dwBandID);
507 if (Band == NULL)
508 return E_FAIL;
509
510 FIXME("Stub\n");
511 return E_NOTIMPL;
512 }
513
514 HRESULT STDMETHODCALLTYPE CBandSiteBase::RemoveBand(DWORD dwBandID)
515 {
516 struct BandObject *Band;
517 UINT uBand;
518
519 TRACE("(%p, %u)\n", this, dwBandID);
520
521 if (fRebarWindow == NULL)
522 return E_FAIL;
523
524 Band = GetBandByID(dwBandID);
525 if (Band == NULL)
526 return E_FAIL;
527
528 uBand = (UINT)SendMessageW(fRebarWindow, RB_IDTOINDEX, (WPARAM)GetBandID(Band), 0);
529 if (uBand != (UINT)-1)
530 {
531 if (!SendMessageW(fRebarWindow, RB_DELETEBAND, (WPARAM)uBand, 0))
532 {
533 ERR("Could not delete band!\n");
534 }
535 }
536 else
537 ERR("Could not map band id to index!\n");
538
539 FreeBand(Band);
540 return S_OK;
541 }
542
543 HRESULT STDMETHODCALLTYPE CBandSiteBase::GetBandObject(DWORD dwBandID, REFIID riid, VOID **ppv)
544 {
545 struct BandObject *Band;
546
547 TRACE("(%p, %u, %s, %p)\n", this, dwBandID, debugstr_guid(&riid), ppv);
548
549 Band = GetBandByID(dwBandID);
550 if (Band == NULL)
551 {
552 *ppv = NULL;
553 return E_FAIL;
554 }
555
556 return Band->DeskBand->QueryInterface(riid, ppv);
557 }
558
559 HRESULT STDMETHODCALLTYPE CBandSiteBase::SetBandSiteInfo(const BANDSITEINFO *pbsinfo)
560 {
561 FIXME("(%p, %p)\n", this, pbsinfo);
562 return E_NOTIMPL;
563 }
564
565 HRESULT STDMETHODCALLTYPE CBandSiteBase::GetBandSiteInfo(BANDSITEINFO *pbsinfo)
566 {
567 FIXME("(%p, %p)\n", this, pbsinfo);
568 return E_NOTIMPL;
569 }
570
571 HRESULT STDMETHODCALLTYPE CBandSiteBase::OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *plrResult)
572 {
573 struct BandObject *Band;
574
575 TRACE("(%p, %p, %u, %p, %p, %p)\n", this, hWnd, uMsg, wParam, lParam, plrResult);
576
577 *plrResult = 0;
578 if (fRebarWindow == NULL)
579 return E_FAIL;
580
581 if (hWnd == fRebarWindow)
582 {
583 /* FIXME: Just send the message? */
584 *plrResult = SendMessageW(hWnd, uMsg, wParam, lParam);
585 return S_OK;
586 }
587
588 Band = GetBandFromHwnd(hWnd);
589 if (Band != NULL)
590 {
591 return Band->WndEvtHandler->OnWinEvent(hWnd, uMsg, wParam, lParam, plrResult);
592 }
593
594 return E_FAIL;
595 }
596
597 HRESULT STDMETHODCALLTYPE CBandSiteBase::IsWindowOwner(HWND hWnd)
598 {
599 struct BandObject *Band;
600
601 TRACE("(%p, %p)\n", this, hWnd);
602
603 if (fRebarWindow == NULL)
604 return E_FAIL;
605
606 Band = GetBandFromHwnd(hWnd);
607 if (Band != NULL)
608 return S_OK;
609
610 return S_FALSE;
611 }
612
613 HRESULT STDMETHODCALLTYPE CBandSiteBase::GetWindow(HWND *phWnd)
614 {
615 TRACE("(%p, %p)\n", this, phWnd);
616
617 *phWnd = fRebarWindow;
618 if (fRebarWindow != NULL)
619 return S_OK;
620
621 return E_FAIL;
622 }
623
624 HRESULT STDMETHODCALLTYPE CBandSiteBase::ContextSensitiveHelp(BOOL fEnterMode)
625 {
626 FIXME("(%p, %d)\n", this, fEnterMode);
627 return E_NOTIMPL;
628 }
629
630 HRESULT STDMETHODCALLTYPE CBandSiteBase::SetDeskBarSite(IUnknown *pUnk)
631 {
632 HWND hWndParent;
633 HRESULT hRet;
634 DWORD style;
635
636 TRACE("(%p, %p)\n", this, pUnk);
637
638 fOleWindow.Release();
639
640 hRet = pUnk->QueryInterface(IID_PPV_ARG(IOleWindow, &fOleWindow));
641 if (FAILED_UNEXPECTEDLY(hRet))
642 return E_FAIL;
643
644 hRet = fOleWindow->GetWindow(&hWndParent);
645 if (FAILED_UNEXPECTEDLY(hRet))
646 return E_FAIL;
647
648 style = WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | RBS_VARHEIGHT | RBS_AUTOSIZE |
649 RBS_BANDBORDERS | CCS_NODIVIDER | CCS_NORESIZE | CCS_NOPARENTALIGN;
650
651 fRebarWindow = CreateWindowExW(WS_EX_TOOLWINDOW,
652 REBARCLASSNAMEW,
653 NULL,
654 style,
655 0, 0, 0, 0,
656 hWndParent,
657 NULL,
658 _AtlBaseModule.GetModuleInstance(),
659 NULL);
660 if (fRebarWindow == NULL)
661 {
662 fOleWindow.Release();
663 WARN("IDeskbarClient::SetDeskBarSite() failed to create ReBar control!\n");
664 return E_FAIL;
665 }
666
667 return S_OK;
668 }
669
670 HRESULT STDMETHODCALLTYPE CBandSiteBase::SetModeDBC(DWORD dwMode)
671 {
672 LONG dwStyle;
673 LONG dwPrevStyle;
674
675 TRACE("(%p, %x)\n", this, dwMode);
676
677 if (fRebarWindow == NULL)
678 return E_FAIL;
679
680 dwStyle = dwPrevStyle = GetWindowLongPtr(fRebarWindow, GWL_STYLE);
681 if (dwMode & DBIF_VIEWMODE_VERTICAL)
682 dwStyle |= CCS_VERT;
683
684 if (dwMode & ~DBIF_VIEWMODE_VERTICAL)
685 FIXME("IDeskBarClient::SetModeDBC() unhandled modes: %x\n", dwStyle & ~DBIF_VIEWMODE_VERTICAL);
686
687 if (dwStyle != dwPrevStyle)
688 {
689 SetWindowLongPtr(fRebarWindow, GWL_STYLE, dwPrevStyle);
690 }
691
692 return S_OK;
693 }
694
695 HRESULT STDMETHODCALLTYPE CBandSiteBase::UIActivateDBC(DWORD dwState)
696 {
697 TRACE("(%p, %x)\n", this, dwState);
698
699 if (fRebarWindow == NULL)
700 return E_FAIL;
701
702 ShowWindow(fRebarWindow, (dwState & DBC_SHOW) ? SW_SHOW : SW_HIDE);
703 //FIXME: Properly notify bands?
704 return S_OK;
705 }
706
707 HRESULT STDMETHODCALLTYPE CBandSiteBase::GetSize(DWORD unknown1, LPRECT unknown2)
708 {
709 FIXME("(%p, %x, %p)\n", this, unknown1, unknown2);
710 return E_NOTIMPL;
711 }
712
713 HRESULT STDMETHODCALLTYPE CBandSiteBase::QueryStatus(const GUID *pguidCmdGroup,
714 DWORD cCmds, OLECMD *prgCmds, OLECMDTEXT *pCmdText)
715 {
716 FIXME("(%p, %p, %u, %p, %p)\n", this, pguidCmdGroup, cCmds, prgCmds, pCmdText);
717 return E_NOTIMPL;
718 }
719
720 HRESULT STDMETHODCALLTYPE CBandSiteBase::Exec(const GUID *pguidCmdGroup, DWORD nCmdID,
721 DWORD nCmdExecOpt, VARIANTARG *pvaIn, VARIANTARG *pvaOut)
722 {
723 HRESULT hRet = S_OK;
724
725 TRACE("(%p, %p, %u, %u, %p, %p)\n", this, pguidCmdGroup, nCmdID, nCmdExecOpt, pvaIn, pvaOut);
726
727 if (fRebarWindow == NULL)
728 return E_FAIL;
729
730 if (IsEqualIID(*pguidCmdGroup, IID_IDeskBand))
731 {
732 switch (nCmdID)
733 {
734 case DBID_BANDINFOCHANGED:
735 if (pvaIn == NULL)
736 hRet = UpdateAllBands();
737 else
738 {
739 /* Update a single band */
740 if (pvaIn->n1.n2.vt == VT_I4)
741 hRet = UpdateBand(pvaIn->n1.n2.n3.lVal);
742 else
743 hRet = E_FAIL;
744 }
745 break;
746
747 case DBID_SHOWONLY:
748 case DBID_MAXIMIZEBAND:
749 case DBID_PUSHCHEVRON:
750 FIXME("IOleCommandTarget::Exec(): Unsupported command ID %d\n", nCmdID);
751 return E_NOTIMPL;
752 default:
753 return E_FAIL;
754 }
755 return hRet;
756 }
757 else
758 WARN("IOleCommandTarget::Exec(): Unsupported command group GUID\n");
759
760 return E_NOTIMPL;
761 }
762
763 HRESULT STDMETHODCALLTYPE CBandSiteBase::UIActivateIO(BOOL fActivate, LPMSG lpMsg)
764 {
765 return E_NOTIMPL;
766 }
767
768 HRESULT STDMETHODCALLTYPE CBandSiteBase::HasFocusIO()
769 {
770 return E_NOTIMPL;
771 }
772
773 HRESULT STDMETHODCALLTYPE CBandSiteBase::TranslateAcceleratorIO(LPMSG lpMsg)
774 {
775 return E_NOTIMPL;
776 }
777
778 HRESULT STDMETHODCALLTYPE CBandSiteBase::OnFocusChangeIS(struct IUnknown *paramC, int param10)
779 {
780 return E_NOTIMPL;
781 }
782
783 HRESULT STDMETHODCALLTYPE CBandSiteBase::QueryService(REFGUID guidService, REFIID riid, void **ppvObject)
784 {
785 return E_NOTIMPL;
786 }
787
788 HRESULT STDMETHODCALLTYPE CBandSiteBase::GetClassID(CLSID *pClassID)
789 {
790 return E_NOTIMPL;
791 }
792
793 HRESULT STDMETHODCALLTYPE CBandSiteBase::IsDirty()
794 {
795 return E_NOTIMPL;
796 }
797
798 HRESULT STDMETHODCALLTYPE CBandSiteBase::Load(IStream *pStm)
799 {
800 return E_NOTIMPL;
801 }
802
803 HRESULT STDMETHODCALLTYPE CBandSiteBase::Save(IStream *pStm, BOOL fClearDirty)
804 {
805 return E_NOTIMPL;
806 }
807
808 HRESULT STDMETHODCALLTYPE CBandSiteBase::GetSizeMax(ULARGE_INTEGER *pcbSize)
809 {
810 return E_NOTIMPL;
811 }
812
813 HRESULT STDMETHODCALLTYPE CBandSiteBase::DragEnter(
814 IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
815 {
816 return E_NOTIMPL;
817 }
818
819 HRESULT STDMETHODCALLTYPE CBandSiteBase::DragOver(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
820 {
821 return E_NOTIMPL;
822 }
823
824 HRESULT STDMETHODCALLTYPE CBandSiteBase::DragLeave()
825 {
826 return E_NOTIMPL;
827 }
828
829 HRESULT STDMETHODCALLTYPE CBandSiteBase::Drop(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
830 {
831 return E_NOTIMPL;
832 }
833
834 HRESULT STDMETHODCALLTYPE CBandSiteBase::LoadFromStreamBS(IStream *, const GUID &, void **)
835 {
836 return E_NOTIMPL;
837 }
838
839 HRESULT STDMETHODCALLTYPE CBandSiteBase::SaveToStreamBS(IUnknown *, IStream *)
840 {
841 return E_NOTIMPL;
842 }