4 * Copyright 2009 Andrew Hill <ash77 at domain reactos.org>
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.
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.
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
22 This class handles the combo box of the address band.
29 Add auto completion support
30 Subclass windows in Init method
31 Connect to browser connection point
32 Handle navigation complete messages to set edit box text
33 Handle listbox dropdown message and fill contents
34 Add drag and drop of icon in edit box
35 Handle enter in edit box to browse to typed path
36 Handle change notifies to update appropriately
37 Add handling of enter in edit box
38 Fix so selection in combo listbox navigates
39 Fix so editing text and typing enter navigates
42 CAddressEditBox::CAddressEditBox() :
43 fCombobox(NULL
, this, 1),
44 fEditWindow(NULL
, this, 1),
49 CAddressEditBox::~CAddressEditBox()
53 HRESULT STDMETHODCALLTYPE
CAddressEditBox::SetOwner(IUnknown
*)
55 // connect to browser connection point
59 HRESULT STDMETHODCALLTYPE
CAddressEditBox::FileSysChange(long param8
, long paramC
)
64 HRESULT STDMETHODCALLTYPE
CAddressEditBox::Refresh(long param8
)
69 HRESULT STDMETHODCALLTYPE
CAddressEditBox::Init(HWND comboboxEx
, HWND editControl
, long param14
, IUnknown
*param18
)
71 CComPtr
<IBrowserService
> browserService
;
73 fCombobox
.SubclassWindow(comboboxEx
);
74 fEditWindow
.SubclassWindow(editControl
);
77 // take advice to watch events
78 HRESULT hResult
= IUnknown_QueryService(param18
, SID_SShellBrowser
, IID_PPV_ARG(IBrowserService
, &browserService
));
79 if (SUCCEEDED(hResult
))
81 hResult
= AtlAdvise(browserService
, static_cast<IDispatch
*>(this), DIID_DWebBrowserEvents
, &fAdviseCookie
);
87 HRESULT STDMETHODCALLTYPE
CAddressEditBox::SetCurrentDir(long paramC
)
92 HRESULT STDMETHODCALLTYPE
CAddressEditBox::ParseNow(long paramC
)
99 CComPtr
<IShellBrowser
> pisb
;
100 hr
= IUnknown_QueryService(fSite
, SID_SShellBrowser
, IID_PPV_ARG(IShellBrowser
, &pisb
));
102 IUnknown_GetWindow(pisb
, &topLevelWindow
);
105 int inputLength
= GetWindowTextLength(fCombobox
.m_hWnd
) + 2;
107 input
= new WCHAR
[inputLength
];
108 GetWindowText(fCombobox
.m_hWnd
, input
, inputLength
);
111 int addressLength
= ExpandEnvironmentStrings(input
, NULL
, 0);
113 if (addressLength
<= 0)
120 address
= new WCHAR
[addressLength
];
121 ExpandEnvironmentStrings(input
, address
, 0);
124 CComPtr
<IShellFolder
> psfDesktop
;
125 hr
= SHGetDesktopFolder(&psfDesktop
);
126 hr
= psfDesktop
->ParseDisplayName(topLevelWindow
, NULL
, address
, &eaten
, &pidlLastParsed
, &attributes
);
128 if (address
!= input
)
135 HRESULT STDMETHODCALLTYPE
CAddressEditBox::Execute(long paramC
)
142 CComPtr
<IShellBrowser
> pisb
;
143 hr
= IUnknown_QueryService(fSite
, SID_SShellBrowser
, IID_PPV_ARG(IShellBrowser
, &pisb
));
146 hr
= pisb
->BrowseObject(pidlLastParsed
, 0);
150 LPCITEMIDLIST pidlChild
;
151 CComPtr
<IShellFolder
> sf
;
152 CComPtr
<IShellBrowser
> pisb
;
154 hr
= IUnknown_QueryService(fSite
, SID_SShellBrowser
, IID_PPV_ARG(IShellBrowser
, &pisb
));
156 IUnknown_GetWindow(pisb
, &topLevelWindow
);
158 hr
= SHBindToParent(pidlLastParsed
, IID_PPV_ARG(IShellFolder
, &sf
), &pidlChild
);
160 SHInvokeDefaultCommand(topLevelWindow
, sf
, pidlChild
);
166 HRESULT STDMETHODCALLTYPE
CAddressEditBox::Save(long paramC
)
171 HRESULT STDMETHODCALLTYPE
CAddressEditBox::OnWinEvent(
172 HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
, LRESULT
*theResult
)
174 // handle fill of listbox here
178 HRESULT STDMETHODCALLTYPE
CAddressEditBox::IsWindowOwner(HWND hWnd
)
180 if (fCombobox
.m_hWnd
== hWnd
)
182 if (fEditWindow
.m_hWnd
== hWnd
)
187 HRESULT STDMETHODCALLTYPE
CAddressEditBox::QueryStatus(
188 const GUID
*pguidCmdGroup
, ULONG cCmds
, OLECMD prgCmds
[ ], OLECMDTEXT
*pCmdText
)
193 HRESULT STDMETHODCALLTYPE
CAddressEditBox::Exec(const GUID
*pguidCmdGroup
, DWORD nCmdID
,
194 DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
199 HRESULT STDMETHODCALLTYPE
CAddressEditBox::GetTypeInfoCount(UINT
*pctinfo
)
204 HRESULT STDMETHODCALLTYPE
CAddressEditBox::GetTypeInfo(UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
209 HRESULT STDMETHODCALLTYPE
CAddressEditBox::GetIDsOfNames(
210 REFIID riid
, LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
215 HRESULT STDMETHODCALLTYPE
CAddressEditBox::Invoke(DISPID dispIdMember
, REFIID riid
, LCID lcid
,
216 WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
218 if (pDispParams
== NULL
)
221 switch (dispIdMember
)
223 case DISPID_NAVIGATECOMPLETE2
:
224 case DISPID_DOCUMENTCOMPLETE
:
225 pidlLastParsed
= NULL
;
230 HRESULT STDMETHODCALLTYPE
CAddressEditBox::GetClassID(CLSID
*pClassID
)
232 if (pClassID
== NULL
)
234 *pClassID
= CLSID_AddressEditBox
;
238 HRESULT STDMETHODCALLTYPE
CAddressEditBox::IsDirty()
243 HRESULT STDMETHODCALLTYPE
CAddressEditBox::Load(IStream
*pStm
)
248 HRESULT STDMETHODCALLTYPE
CAddressEditBox::Save(IStream
*pStm
, BOOL fClearDirty
)
253 HRESULT STDMETHODCALLTYPE
CAddressEditBox::GetSizeMax(ULARGE_INTEGER
*pcbSize
)
258 HRESULT
CreateAddressEditBox(REFIID riid
, void **ppv
)
260 CComObject
<CAddressEditBox
> *theMenuBar
;
266 ATLTRY (theMenuBar
= new CComObject
<CAddressEditBox
>);
267 if (theMenuBar
== NULL
)
268 return E_OUTOFMEMORY
;
269 hResult
= theMenuBar
->QueryInterface(riid
, reinterpret_cast<void **>(ppv
));