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 if (SUCCEEDED(hResult
))
82 hResult
= AtlAdvise(browserService
, static_cast<IDispatch
*>(this), DIID_DWebBrowserEvents
, &fAdviseCookie
);
88 HRESULT STDMETHODCALLTYPE
CAddressEditBox::SetCurrentDir(long paramC
)
93 HRESULT STDMETHODCALLTYPE
CAddressEditBox::ParseNow(long paramC
)
101 CComPtr
<IShellBrowser
> pisb
;
102 hr
= IUnknown_QueryService(fSite
, SID_SShellBrowser
, IID_PPV_ARG(IShellBrowser
, &pisb
));
104 IUnknown_GetWindow(pisb
, &topLevelWindow
);
106 GetWindowText(fCombobox
.m_hWnd
, address
, 4095);
108 CComPtr
<IShellFolder
> psfDesktop
;
109 hr
= SHGetDesktopFolder(&psfDesktop
);
110 hr
= psfDesktop
->ParseDisplayName(topLevelWindow
, NULL
, address
, &eaten
, &pidlLastParsed
, &attributes
);
114 HRESULT STDMETHODCALLTYPE
CAddressEditBox::Execute(long paramC
)
121 CComPtr
<IShellBrowser
> pisb
;
122 hr
= IUnknown_QueryService(fSite
, SID_SShellBrowser
, IID_PPV_ARG(IShellBrowser
, &pisb
));
125 hr
= pisb
->BrowseObject(pidlLastParsed
, 0);
129 LPCITEMIDLIST pidlChild
;
130 CComPtr
<IShellFolder
> sf
;
131 CComPtr
<IShellBrowser
> pisb
;
133 hr
= IUnknown_QueryService(fSite
, SID_SShellBrowser
, IID_PPV_ARG(IShellBrowser
, &pisb
));
135 IUnknown_GetWindow(pisb
, &topLevelWindow
);
137 hr
= SHBindToParent(pidlLastParsed
, IID_PPV_ARG(IShellFolder
, &sf
), &pidlChild
);
139 SHInvokeDefaultCommand(topLevelWindow
, sf
, pidlChild
);
145 HRESULT STDMETHODCALLTYPE
CAddressEditBox::Save(long paramC
)
150 HRESULT STDMETHODCALLTYPE
CAddressEditBox::OnWinEvent(
151 HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
, LRESULT
*theResult
)
153 // handle fill of listbox here
157 HRESULT STDMETHODCALLTYPE
CAddressEditBox::IsWindowOwner(HWND hWnd
)
159 if (fCombobox
.m_hWnd
== hWnd
)
161 if (fEditWindow
.m_hWnd
== hWnd
)
166 HRESULT STDMETHODCALLTYPE
CAddressEditBox::QueryStatus(
167 const GUID
*pguidCmdGroup
, ULONG cCmds
, OLECMD prgCmds
[ ], OLECMDTEXT
*pCmdText
)
172 HRESULT STDMETHODCALLTYPE
CAddressEditBox::Exec(const GUID
*pguidCmdGroup
, DWORD nCmdID
,
173 DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
178 HRESULT STDMETHODCALLTYPE
CAddressEditBox::GetTypeInfoCount(UINT
*pctinfo
)
183 HRESULT STDMETHODCALLTYPE
CAddressEditBox::GetTypeInfo(UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
188 HRESULT STDMETHODCALLTYPE
CAddressEditBox::GetIDsOfNames(
189 REFIID riid
, LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
194 HRESULT STDMETHODCALLTYPE
CAddressEditBox::Invoke(DISPID dispIdMember
, REFIID riid
, LCID lcid
,
195 WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
197 if (pDispParams
== NULL
)
200 switch (dispIdMember
)
202 case DISPID_NAVIGATECOMPLETE2
:
203 case DISPID_DOCUMENTCOMPLETE
:
204 pidlLastParsed
= NULL
;
209 HRESULT STDMETHODCALLTYPE
CAddressEditBox::GetClassID(CLSID
*pClassID
)
211 if (pClassID
== NULL
)
213 *pClassID
= CLSID_AddressEditBox
;
217 HRESULT STDMETHODCALLTYPE
CAddressEditBox::IsDirty()
222 HRESULT STDMETHODCALLTYPE
CAddressEditBox::Load(IStream
*pStm
)
227 HRESULT STDMETHODCALLTYPE
CAddressEditBox::Save(IStream
*pStm
, BOOL fClearDirty
)
232 HRESULT STDMETHODCALLTYPE
CAddressEditBox::GetSizeMax(ULARGE_INTEGER
*pcbSize
)
237 HRESULT
CreateAddressEditBox(REFIID riid
, void **ppv
)
239 CComObject
<CAddressEditBox
> *theMenuBar
;
245 ATLTRY (theMenuBar
= new CComObject
<CAddressEditBox
>);
246 if (theMenuBar
== NULL
)
247 return E_OUTOFMEMORY
;
248 hResult
= theMenuBar
->QueryInterface(riid
, reinterpret_cast<void **>(ppv
));