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