[BROWSEUI]
[reactos.git] / reactos / dll / win32 / browseui / addressband.cpp
1 /*
2 * ReactOS Explorer
3 *
4 * Copyright 2009 Andrew Hill <ash77 at domain reactos.org>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21 /*
22 Implements the navigation band of the cabinet window
23 */
24
25 #include "precomp.h"
26 #include <commoncontrols.h>
27 #include <shlwapi_undoc.h>
28 #include <shellapi.h>
29
30 /*
31 TODO:
32 ****Add command handler for show/hide Go button to OnWinEvent
33 ****Add tooltip notify handler
34 **Properly implement GetBandInfo
35 **Add correct text to Go button
36 **Implement TranslateAcceleratorIO
37 Implement Exec
38 Implement QueryService
39 Implement Load
40 Implement Save
41 */
42
43 CAddressBand::CAddressBand()
44 {
45 fEditControl = NULL;
46 fGoButton = NULL;
47 fComboBox = NULL;
48 fGoButtonShown = false;
49 fAdviseCookie = 0;
50 }
51
52 CAddressBand::~CAddressBand()
53 {
54 }
55
56 void CAddressBand::FocusChange(BOOL bFocus)
57 {
58 // m_bFocus = bFocus;
59
60 //Inform the input object site that the focus has changed.
61 if (fSite)
62 {
63 #if 0
64 fSite->OnFocusChangeIS((IDockingWindow *)this, bFocus);
65 #endif
66 }
67 }
68
69 HRESULT STDMETHODCALLTYPE CAddressBand::GetBandInfo(DWORD dwBandID, DWORD dwViewMode, DESKBANDINFO *pdbi)
70 {
71 if (pdbi->dwMask & DBIM_MINSIZE)
72 {
73 pdbi->ptMinSize.x = 400;
74 pdbi->ptMinSize.y = 22;
75 }
76 if (pdbi->dwMask & DBIM_MAXSIZE)
77 {
78 pdbi->ptMaxSize.x = 0;
79 pdbi->ptMaxSize.y = 0;
80 }
81 if (pdbi->dwMask & DBIM_INTEGRAL)
82 {
83 pdbi->ptIntegral.x = 0;
84 pdbi->ptIntegral.y = 0;
85 }
86 if (pdbi->dwMask & DBIM_ACTUAL)
87 {
88 pdbi->ptActual.x = 400;
89 pdbi->ptActual.y = 22;
90 }
91 if (pdbi->dwMask & DBIM_TITLE)
92 {
93 if (!LoadStringW(_AtlBaseModule.GetResourceInstance(), IDS_ADDRESSBANDLABEL, pdbi->wszTitle, _countof(pdbi->wszTitle)))
94 return HRESULT_FROM_WIN32(GetLastError());
95 }
96
97 if (pdbi->dwMask & DBIM_MODEFLAGS)
98 pdbi->dwModeFlags = DBIMF_UNDELETEABLE;
99 if (pdbi->dwMask & DBIM_BKCOLOR)
100 pdbi->crBkgnd = 0;
101 return S_OK;
102 }
103
104 HRESULT STDMETHODCALLTYPE CAddressBand::SetSite(IUnknown *pUnkSite)
105 {
106 CComPtr<IBrowserService> browserService;
107 CComPtr<IShellService> shellService;
108 HWND parentWindow;
109 HWND combobox;
110 HRESULT hResult;
111 IImageList *piml;
112
113 if (pUnkSite == NULL)
114 {
115 hResult = AtlUnadvise(fSite, DIID_DWebBrowserEvents, fAdviseCookie);
116 fSite.Release();
117 return S_OK;
118 }
119
120 fSite.Release();
121
122 hResult = pUnkSite->QueryInterface(IID_PPV_ARG(IDockingWindowSite, &fSite));
123 if (FAILED_UNEXPECTEDLY(hResult))
124 return hResult;
125
126 // get window handle of parent
127 parentWindow = NULL;
128 hResult = IUnknown_GetWindow(fSite, &parentWindow);
129
130 if (!::IsWindow(parentWindow))
131 return E_FAIL;
132
133 // create combo box ex
134 combobox = CreateWindowEx(WS_EX_TOOLWINDOW, WC_COMBOBOXEXW, NULL, WS_CHILD | WS_VISIBLE |
135 WS_CLIPCHILDREN | WS_TABSTOP | CCS_NODIVIDER | CCS_NOMOVEY | CBS_OWNERDRAWFIXED,
136 0, 0, 500, 250, parentWindow, (HMENU)IDM_TOOLBARS_ADDRESSBAR, _AtlBaseModule.GetModuleInstance(), 0);
137 if (combobox == NULL)
138 return E_FAIL;
139 SubclassWindow(combobox);
140
141 HRESULT hr = SHGetImageList(SHIL_SMALL, IID_PPV_ARG(IImageList, &piml));
142 if (FAILED_UNEXPECTEDLY(hr))
143 {
144 SendMessageW(combobox, CBEM_SETIMAGELIST, 0, 0);
145 }
146 else
147 {
148 SendMessageW(combobox, CBEM_SETIMAGELIST, 0, reinterpret_cast<LPARAM>(piml));
149 }
150
151 SendMessage(CBEM_SETEXTENDEDSTYLE,
152 CBES_EX_CASESENSITIVE | CBES_EX_NOSIZELIMIT, CBES_EX_CASESENSITIVE | CBES_EX_NOSIZELIMIT);
153
154 fEditControl = reinterpret_cast<HWND>(SendMessage(CBEM_GETEDITCONTROL, 0, 0));
155 fComboBox = reinterpret_cast<HWND>(SendMessage(CBEM_GETCOMBOCONTROL, 0, 0));
156 hResult = CAddressEditBox_CreateInstance(IID_PPV_ARG(IAddressEditBox, &fAddressEditBox));
157 if (FAILED_UNEXPECTEDLY(hResult))
158 return hResult;
159
160 hResult = fAddressEditBox->QueryInterface(IID_PPV_ARG(IShellService, &shellService));
161 if (FAILED_UNEXPECTEDLY(hResult))
162 return hResult;
163 hResult = fAddressEditBox->Init(combobox, fEditControl, 8, fSite /*(IAddressBand *)this*/);
164 if (FAILED_UNEXPECTEDLY(hResult))
165 return hResult;
166 hResult = shellService->SetOwner(fSite);
167 if (FAILED_UNEXPECTEDLY(hResult))
168 return hResult;
169
170 fGoButtonShown = SHRegGetBoolUSValueW(L"Software\\Microsoft\\Internet Explorer\\Main", L"ShowGoButton", FALSE, TRUE);
171 if (fGoButtonShown)
172 CreateGoButton();
173
174 // take advice to watch events
175 hResult = IUnknown_QueryService(pUnkSite, SID_SShellBrowser, IID_PPV_ARG(IBrowserService, &browserService));
176 if (SUCCEEDED(hResult))
177 {
178 hResult = AtlAdvise(browserService, static_cast<IDispatch *>(this), DIID_DWebBrowserEvents, &fAdviseCookie);
179 }
180
181 return hResult;
182 }
183
184 HRESULT STDMETHODCALLTYPE CAddressBand::GetSite(REFIID riid, void **ppvSite)
185 {
186 if (fSite == NULL)
187 return E_FAIL;
188 return fSite->QueryInterface(riid, ppvSite);
189 }
190
191 HRESULT STDMETHODCALLTYPE CAddressBand::GetWindow(HWND *lphwnd)
192 {
193 if (lphwnd == NULL)
194 return E_POINTER;
195 *lphwnd = m_hWnd;
196 return S_OK;
197 }
198
199 HRESULT STDMETHODCALLTYPE CAddressBand::ContextSensitiveHelp(BOOL fEnterMode)
200 {
201 return E_NOTIMPL;
202 }
203
204 HRESULT STDMETHODCALLTYPE CAddressBand::CloseDW(DWORD dwReserved)
205 {
206 ShowDW(FALSE);
207
208 if (IsWindow())
209 DestroyWindow();
210
211 m_hWnd = NULL;
212
213 IUnknown_SetSite(fAddressEditBox, NULL);
214
215 if (fAddressEditBox) fAddressEditBox.Release();
216 if (fSite) fSite.Release();
217
218 return S_OK;
219 }
220
221 HRESULT STDMETHODCALLTYPE CAddressBand::ResizeBorderDW(
222 const RECT *prcBorder, IUnknown *punkToolbarSite, BOOL fReserved)
223 {
224 return E_NOTIMPL;
225 }
226
227 HRESULT STDMETHODCALLTYPE CAddressBand::ShowDW(BOOL fShow)
228 {
229 if (m_hWnd)
230 {
231 if (fShow)
232 ShowWindow(SW_SHOW);
233 else
234 ShowWindow(SW_HIDE);
235 }
236 return S_OK;
237 }
238
239 HRESULT STDMETHODCALLTYPE CAddressBand::QueryStatus(
240 const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[ ], OLECMDTEXT *pCmdText)
241 {
242 return IUnknown_QueryStatus(fAddressEditBox, *pguidCmdGroup, cCmds, prgCmds, pCmdText);
243 }
244
245 HRESULT STDMETHODCALLTYPE CAddressBand::Exec(const GUID *pguidCmdGroup,
246 DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
247 {
248 // incomplete
249 return E_NOTIMPL;
250 }
251
252 HRESULT STDMETHODCALLTYPE CAddressBand::HasFocusIO()
253 {
254 if (GetFocus() == fEditControl || SendMessage(CB_GETDROPPEDSTATE, 0, 0))
255 return S_OK;
256 return S_FALSE;
257 }
258
259 HRESULT STDMETHODCALLTYPE CAddressBand::TranslateAcceleratorIO(LPMSG lpMsg)
260 {
261 if (lpMsg->hwnd == fEditControl)
262 {
263 switch (lpMsg->message)
264 {
265 case WM_SYSKEYDOWN:
266 case WM_SYSKEYUP:
267 case WM_SYSCOMMAND:
268 case WM_SYSDEADCHAR:
269 case WM_SYSCHAR:
270 return S_FALSE;
271 }
272
273 TranslateMessage(lpMsg);
274 DispatchMessage(lpMsg);
275 return S_OK;
276 }
277 return S_FALSE;
278 }
279
280 HRESULT STDMETHODCALLTYPE CAddressBand::UIActivateIO(BOOL fActivate, LPMSG lpMsg)
281 {
282 if (fActivate)
283 {
284 IUnknown_OnFocusChangeIS(fSite, static_cast<IDeskBand *>(this), fActivate);
285 SetFocus();
286 }
287 return S_OK;
288 }
289
290 HRESULT STDMETHODCALLTYPE CAddressBand::OnWinEvent(
291 HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *theResult)
292 {
293 CComPtr<IWinEventHandler> winEventHandler;
294 HRESULT hResult;
295 RECT rect;
296
297 *theResult = 0;
298
299 switch (uMsg)
300 {
301 case WM_WININICHANGE:
302 break;
303 case WM_COMMAND:
304 if (wParam == IDM_TOOLBARS_GOBUTTON)
305 {
306 fGoButtonShown = !SHRegGetBoolUSValueW(L"Software\\Microsoft\\Internet Explorer\\Main", L"ShowGoButton", FALSE, TRUE);
307 SHRegSetUSValueW(L"Software\\Microsoft\\Internet Explorer\\Main", L"ShowGoButton", REG_SZ, fGoButtonShown ? (LPVOID)L"yes" : (LPVOID)L"no", fGoButtonShown ? 8 : 6, SHREGSET_FORCE_HKCU);
308 if (!fGoButton)
309 CreateGoButton();
310 ::ShowWindow(fGoButton,fGoButtonShown ? SW_HIDE : SW_SHOW);
311 GetWindowRect(&rect);
312 SendMessage(m_hWnd,WM_SIZE,0,MAKELPARAM(rect.right-rect.left,rect.bottom-rect.top));
313 // broadcast change notification to all explorer windows
314 }
315 break;
316 }
317 hResult = fAddressEditBox->QueryInterface(IID_PPV_ARG(IWinEventHandler, &winEventHandler));
318 if (FAILED_UNEXPECTEDLY(hResult))
319 return hResult;
320 return winEventHandler->OnWinEvent(hWnd, uMsg, wParam, lParam, theResult);
321 }
322
323 HRESULT STDMETHODCALLTYPE CAddressBand::IsWindowOwner(HWND hWnd)
324 {
325 CComPtr<IWinEventHandler> winEventHandler;
326 HRESULT hResult;
327
328 if (fAddressEditBox)
329 {
330 hResult = fAddressEditBox->QueryInterface(IID_PPV_ARG(IWinEventHandler, &winEventHandler));
331 if (FAILED_UNEXPECTEDLY(hResult))
332 return hResult;
333 return winEventHandler->IsWindowOwner(hWnd);
334 }
335 return S_FALSE;
336 }
337
338 HRESULT STDMETHODCALLTYPE CAddressBand::FileSysChange(long param8, long paramC)
339 {
340 CComPtr<IAddressBand> addressBand;
341 HRESULT hResult;
342
343 hResult = fAddressEditBox->QueryInterface(IID_PPV_ARG(IAddressBand, &addressBand));
344 if (FAILED_UNEXPECTEDLY(hResult))
345 return hResult;
346 return addressBand->FileSysChange(param8, paramC);
347 }
348
349 HRESULT STDMETHODCALLTYPE CAddressBand::Refresh(long param8)
350 {
351 CComPtr<IAddressBand> addressBand;
352 HRESULT hResult;
353
354 hResult = fAddressEditBox->QueryInterface(IID_PPV_ARG(IAddressBand, &addressBand));
355 if (FAILED_UNEXPECTEDLY(hResult))
356 return hResult;
357 return addressBand->Refresh(param8);
358 }
359
360 HRESULT STDMETHODCALLTYPE CAddressBand::QueryService(REFGUID guidService, REFIID riid, void **ppvObject)
361 {
362 return E_NOTIMPL;
363 }
364
365 HRESULT STDMETHODCALLTYPE CAddressBand::OnFocusChangeIS(IUnknown *punkObj, BOOL fSetFocus)
366 {
367 return E_NOTIMPL;
368 }
369
370 HRESULT STDMETHODCALLTYPE CAddressBand::GetClassID(CLSID *pClassID)
371 {
372 if (pClassID == NULL)
373 return E_POINTER;
374 *pClassID = CLSID_SH_AddressBand;
375 return S_OK;
376 }
377
378 HRESULT STDMETHODCALLTYPE CAddressBand::IsDirty()
379 {
380 return E_NOTIMPL;
381 }
382
383 HRESULT STDMETHODCALLTYPE CAddressBand::Load(IStream *pStm)
384 {
385 // incomplete
386 return E_NOTIMPL;
387 }
388
389 HRESULT STDMETHODCALLTYPE CAddressBand::Save(IStream *pStm, BOOL fClearDirty)
390 {
391 // incomplete
392 return E_NOTIMPL;
393 }
394
395 HRESULT STDMETHODCALLTYPE CAddressBand::GetSizeMax(ULARGE_INTEGER *pcbSize)
396 {
397 // incomplete
398 return E_NOTIMPL;
399 }
400
401 HRESULT STDMETHODCALLTYPE CAddressBand::GetTypeInfoCount(UINT *pctinfo)
402 {
403 return E_NOTIMPL;
404 }
405
406 HRESULT STDMETHODCALLTYPE CAddressBand::GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
407 {
408 return E_NOTIMPL;
409 }
410
411 HRESULT STDMETHODCALLTYPE CAddressBand::GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames,
412 LCID lcid, DISPID *rgDispId)
413 {
414 return E_NOTIMPL;
415 }
416
417 HRESULT STDMETHODCALLTYPE CAddressBand::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags,
418 DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
419 {
420 CComPtr<IBrowserService> isb;
421 CComPtr<IShellFolder> sf;
422 HRESULT hr;
423 INT indexClosed, indexOpen, itemExists, oldIndex;
424 DWORD result;
425 COMBOBOXEXITEMW item;
426 PIDLIST_ABSOLUTE absolutePIDL;
427 LPCITEMIDLIST pidlChild;
428 LPITEMIDLIST pidlPrevious;
429 STRRET ret;
430 WCHAR buf[4096];
431
432 if (pDispParams == NULL)
433 return E_INVALIDARG;
434
435 switch (dispIdMember)
436 {
437 case DISPID_NAVIGATECOMPLETE2:
438 case DISPID_DOCUMENTCOMPLETE:
439
440 oldIndex = SendMessage(m_hWnd, CB_GETCURSEL, 0, 0);
441
442 itemExists = FALSE;
443 pidlPrevious = NULL;
444
445 ZeroMemory(&item, sizeof(item));
446 item.mask = CBEIF_LPARAM;
447 item.iItem = 0;
448 if (SendMessage(m_hWnd, CBEM_GETITEM, 0, reinterpret_cast<LPARAM>(&item)))
449 {
450 pidlPrevious = reinterpret_cast<LPITEMIDLIST>(item.lParam);
451 if (pidlPrevious)
452 itemExists = TRUE;
453 }
454
455 hr = IUnknown_QueryService(fSite, SID_STopLevelBrowser, IID_PPV_ARG(IBrowserService, &isb));
456 if (FAILED_UNEXPECTEDLY(hr))
457 return hr;
458 isb->GetPidl(&absolutePIDL);
459
460 SHBindToParent(absolutePIDL, IID_PPV_ARG(IShellFolder, &sf), &pidlChild);
461
462 sf->GetDisplayNameOf(pidlChild, SHGDN_FORADDRESSBAR | SHGDN_FORPARSING, &ret);
463
464 StrRetToBufW(&ret, pidlChild, buf, 4095);
465
466 indexClosed = SHMapPIDLToSystemImageListIndex(sf, pidlChild, &indexOpen);
467
468 item.mask = CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBEIF_TEXT | CBEIF_LPARAM;
469 item.iItem = 0;
470 item.iImage = indexClosed;
471 item.iSelectedImage = indexOpen;
472 item.pszText = buf;
473 item.lParam = reinterpret_cast<LPARAM>(absolutePIDL);
474
475 if (itemExists)
476 {
477 result = SendMessage(m_hWnd, CBEM_SETITEM, 0, reinterpret_cast<LPARAM>(&item));
478 oldIndex = 0;
479
480 if (result)
481 {
482 ILFree(pidlPrevious);
483 }
484 }
485 else
486 {
487 oldIndex = SendMessage(m_hWnd, CBEM_INSERTITEM, 0, reinterpret_cast<LPARAM>(&item));
488
489 if (oldIndex < 0)
490 DbgPrint("ERROR %d\n", GetLastError());
491 }
492
493 SendMessage(m_hWnd, CB_SETCURSEL, -1, 0);
494 SendMessage(m_hWnd, CB_SETCURSEL, oldIndex, 0);
495
496 //fAddressEditBox->SetCurrentDir(index);
497
498 break;
499 }
500 return S_OK;
501 }
502
503 LRESULT CAddressBand::OnNotifyClick(WPARAM wParam, NMHDR *notifyHeader, BOOL &bHandled)
504 {
505 if (notifyHeader->hwndFrom == fGoButton)
506 {
507 fAddressEditBox->Execute(0);
508 }
509 return 0;
510 }
511
512 LRESULT CAddressBand::OnTipText(UINT idControl, NMHDR *notifyHeader, BOOL &bHandled)
513 {
514 if (notifyHeader->hwndFrom == fGoButton)
515 {
516 // TODO
517 // Go to "destination path"
518 }
519 return 0;
520 }
521
522 LRESULT CAddressBand::OnEraseBackground(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
523 {
524 POINT pt;
525 POINT ptOrig;
526 HWND parentWindow;
527 LRESULT result;
528
529 if (fGoButtonShown == false)
530 {
531 bHandled = FALSE;
532 return 0;
533 }
534 pt.x = 0;
535 pt.y = 0;
536 parentWindow = GetParent();
537 ::MapWindowPoints(m_hWnd, parentWindow, &pt, 1);
538 OffsetWindowOrgEx(reinterpret_cast<HDC>(wParam), pt.x, pt.y, &ptOrig);
539 result = SendMessage(parentWindow, WM_ERASEBKGND, wParam, 0);
540 SetWindowOrgEx(reinterpret_cast<HDC>(wParam), ptOrig.x, ptOrig.y, NULL);
541 if (result == 0)
542 {
543 bHandled = FALSE;
544 return 0;
545 }
546 return result;
547 }
548
549 LRESULT CAddressBand::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
550 {
551 RECT goButtonBounds;
552 RECT buttonBounds;
553 long buttonWidth;
554 long buttonHeight;
555 RECT comboBoxBounds;
556 long newHeight;
557 long newWidth;
558
559 if (fGoButtonShown == false)
560 {
561 bHandled = FALSE;
562 return 0;
563 }
564
565 newHeight = HIWORD(lParam);
566 newWidth = LOWORD(lParam);
567
568 if (!fGoButton)
569 CreateGoButton();
570
571 SendMessage(fGoButton, TB_GETITEMRECT, 0, reinterpret_cast<LPARAM>(&buttonBounds));
572 buttonWidth = buttonBounds.right - buttonBounds.left;
573 buttonHeight = buttonBounds.bottom - buttonBounds.top;
574
575 DefWindowProc(WM_SIZE, wParam, MAKELONG(newWidth - buttonWidth - 2, newHeight));
576 ::GetWindowRect(fComboBox, &comboBoxBounds);
577 ::SetWindowPos(fGoButton, NULL, newWidth - buttonWidth, (comboBoxBounds.bottom - comboBoxBounds.top - buttonHeight) / 2,
578 buttonWidth, buttonHeight, SWP_NOOWNERZORDER | SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER);
579
580 goButtonBounds.left = newWidth - buttonWidth;
581 goButtonBounds.top = 0;
582 goButtonBounds.right = newWidth - buttonWidth;
583 goButtonBounds.bottom = newHeight;
584 InvalidateRect(&goButtonBounds, TRUE);
585
586 SendMessage(fComboBox, CB_SETDROPPEDWIDTH, 200, 0);
587 return 0;
588 }
589
590 LRESULT CAddressBand::OnWindowPosChanging(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
591 {
592 RECT goButtonBounds;
593 RECT buttonBounds;
594 long buttonWidth;
595 long buttonHeight;
596 RECT comboBoxBounds;
597 WINDOWPOS positionInfoCopy;
598 long newHeight;
599 long newWidth;
600
601 if (!fGoButtonShown)
602 {
603 bHandled = FALSE;
604 return 0;
605 }
606
607 if (!fGoButton)
608 CreateGoButton();
609
610 positionInfoCopy = *reinterpret_cast<WINDOWPOS *>(lParam);
611 newHeight = positionInfoCopy.cy;
612 newWidth = positionInfoCopy.cx;
613 SendMessage(fGoButton, TB_GETITEMRECT, 0, reinterpret_cast<LPARAM>(&buttonBounds));
614
615 buttonWidth = buttonBounds.right - buttonBounds.left;
616 buttonHeight = buttonBounds.bottom - buttonBounds.top;
617 positionInfoCopy.cx = newWidth - 2 - buttonWidth;
618 DefWindowProc(WM_WINDOWPOSCHANGING, wParam, reinterpret_cast<LPARAM>(&positionInfoCopy));
619 ::GetWindowRect(fComboBox, &comboBoxBounds);
620 ::SetWindowPos(fGoButton, NULL, newWidth - buttonWidth, (comboBoxBounds.bottom - comboBoxBounds.top - buttonHeight) / 2,
621 buttonWidth, buttonHeight, SWP_NOOWNERZORDER | SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER);
622
623 goButtonBounds.left = newWidth - buttonWidth;
624 goButtonBounds.top = 0;
625 goButtonBounds.right = newWidth - buttonWidth;
626 goButtonBounds.bottom = newHeight;
627 InvalidateRect(&goButtonBounds, TRUE);
628
629 SendMessage(fComboBox, CB_SETDROPPEDWIDTH, 200, 0);
630 return 0;
631 }
632
633 void CAddressBand::CreateGoButton()
634 {
635 const TBBUTTON buttonInfo [] = { { 0, 1, TBSTATE_ENABLED, 0 } };
636 HIMAGELIST normalImagelist;
637 HIMAGELIST hotImageList;
638 HINSTANCE shellInstance;
639
640
641 shellInstance = GetModuleHandle(_T("shell32.dll"));
642 normalImagelist = ImageList_LoadImageW(shellInstance, MAKEINTRESOURCE(IDB_GOBUTTON_NORMAL),
643 20, 0, RGB(255, 0, 255), IMAGE_BITMAP, LR_CREATEDIBSECTION);
644 hotImageList = ImageList_LoadImageW(shellInstance, MAKEINTRESOURCE(IDB_GOBUTTON_HOT),
645 20, 0, RGB(255, 0, 255), IMAGE_BITMAP, LR_CREATEDIBSECTION);
646
647 fGoButton = CreateWindowEx(WS_EX_TOOLWINDOW, TOOLBARCLASSNAMEW, 0, WS_CHILD | WS_CLIPSIBLINGS |
648 WS_CLIPCHILDREN | TBSTYLE_LIST | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS | CCS_NODIVIDER |
649 CCS_NOPARENTALIGN | CCS_NORESIZE,
650 0, 0, 0, 0, m_hWnd, NULL, _AtlBaseModule.GetModuleInstance(), NULL);
651 SendMessage(fGoButton, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
652 SendMessage(fGoButton, TB_SETMAXTEXTROWS, 1, 0);
653 if (normalImagelist)
654 SendMessage(fGoButton, TB_SETIMAGELIST, 0, reinterpret_cast<LPARAM>(normalImagelist));
655 if (hotImageList)
656 SendMessage(fGoButton, TB_SETHOTIMAGELIST, 0, reinterpret_cast<LPARAM>(hotImageList));
657 SendMessage(fGoButton, TB_ADDSTRINGW,
658 reinterpret_cast<WPARAM>(_AtlBaseModule.GetResourceInstance()), IDS_GOBUTTONLABEL);
659 SendMessage(fGoButton, TB_ADDBUTTONSW, 1, (LPARAM) &buttonInfo);
660 }