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