source: trunk/src/comdlg32/filedlgbrowser.c@ 5280

Last change on this file since 5280 was 4561, checked in by sandervl, 25 years ago

merged with latest Wine (11-05-2000)

File size: 28.2 KB
Line 
1/*
2 * Implementation of IShellBrowser for the File Open common dialog
3 *
4 *
5 */
6
7#ifdef __WIN32OS2__
8#include <windef.h>
9#include <winbase.h>
10#include <wingdi.h>
11#include <winuser.h>
12#include <heapstring.h>
13#include <misc.h>
14
15#endif
16
17#include <stdio.h>
18#include "unknwn.h"
19#include "filedlgbrowser.h"
20#include "windef.h"
21#include "wingdi.h"
22#include "winuser.h"
23#include "wine/winestring.h"
24#include "heap.h"
25#include "shlguid.h"
26#include "wine/obj_dataobject.h"
27#include "debugtools.h"
28#include "cdlg.h"
29
30#define INITGUID
31#include "initguid.h"
32#include "wine/obj_serviceprovider.h"
33
34DEFAULT_DEBUG_CHANNEL(commdlg);
35
36typedef struct
37{
38
39 ICOM_VTABLE(IShellBrowser) * lpVtbl;
40 ICOM_VTABLE(ICommDlgBrowser) * lpVtblCommDlgBrowser;
41 ICOM_VTABLE(IServiceProvider)* lpVtblServiceProvider;
42 DWORD ref; /* Reference counter */
43 HWND hwndOwner; /* Owner dialog of the interface */
44
45} IShellBrowserImpl;
46
47/**************************************************************************
48* vtable
49*/
50static ICOM_VTABLE(IShellBrowser) IShellBrowserImpl_Vtbl;
51static ICOM_VTABLE(ICommDlgBrowser) IShellBrowserImpl_ICommDlgBrowser_Vtbl;
52static ICOM_VTABLE(IServiceProvider) IShellBrowserImpl_IServiceProvider_Vtbl;
53
54/**************************************************************************
55* Local Prototypes
56*/
57
58HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IShellView *ppshv);
59#if 0
60LPITEMIDLIST GetSelectedPidl(IShellView *ppshv);
61#endif
62
63/**************************************************************************
64* External Prototypes
65*/
66extern const char *FileOpenDlgInfosStr;
67
68extern HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPSTR lpstrFileName);
69extern HRESULT GetFileName(HWND hwnd, LPITEMIDLIST pidl, LPSTR lpstrFileName);
70extern IShellFolder* GetShellFolderFromPidl(LPITEMIDLIST pidlAbs);
71extern LPITEMIDLIST GetParentPidl(LPITEMIDLIST pidl);
72extern LPITEMIDLIST GetPidlFromName(IShellFolder *psf,LPCSTR lpcstrFileName);
73
74extern BOOL FILEDLG95_SHELL_FillIncludedItemList(HWND hwnd,
75 LPITEMIDLIST pidlCurrentFolder,
76 LPSTR lpstrMask);
77
78extern int FILEDLG95_LOOKIN_SelectItem(HWND hwnd,LPITEMIDLIST pidl);
79extern BOOL FILEDLG95_OnOpen(HWND hwnd);
80extern HRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode);
81
82
83/*
84 * Helper functions
85 */
86
87/* copied from shell32 to avoid linking to it */
88static HRESULT COMDLG32_StrRetToStrNW (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl)
89{
90 TRACE("dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest,len,src,pidl);
91
92 switch (src->uType)
93 {
94 case STRRET_WSTR:
95 lstrcpynW((LPWSTR)dest, src->u.pOleStr, len);
96 COMDLG32_SHFree(src->u.pOleStr);
97 break;
98
99 case STRRET_CSTRA:
100 lstrcpynAtoW((LPWSTR)dest, src->u.cStr, len);
101 break;
102
103 case STRRET_OFFSETA:
104 if (pidl)
105 {
106 lstrcpynAtoW((LPWSTR)dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len);
107 }
108 break;
109
110 default:
111 FIXME("unknown type!\n");
112 if (len)
113 { *(LPSTR)dest = '\0';
114 }
115 return(FALSE);
116 }
117 return S_OK;
118}
119
120/*
121 * IShellBrowser
122 */
123
124/**************************************************************************
125* IShellBrowserImpl_Construct
126*/
127IShellBrowser * IShellBrowserImpl_Construct(HWND hwndOwner)
128{
129 IShellBrowserImpl *sb;
130 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwndOwner,FileOpenDlgInfosStr);
131
132 sb=(IShellBrowserImpl*)COMDLG32_SHAlloc(sizeof(IShellBrowserImpl));
133
134 /* Initialisation of the member variables */
135 sb->ref=1;
136 sb->hwndOwner = hwndOwner;
137
138 /* Initialisation of the vTables */
139 sb->lpVtbl = &IShellBrowserImpl_Vtbl;
140 sb->lpVtblCommDlgBrowser = &IShellBrowserImpl_ICommDlgBrowser_Vtbl;
141 sb->lpVtblServiceProvider = &IShellBrowserImpl_IServiceProvider_Vtbl;
142 COMDLG32_SHGetSpecialFolderLocation(hwndOwner, CSIDL_DESKTOP,
143 &fodInfos->ShellInfos.pidlAbsCurrent);
144
145 TRACE("%p\n", sb);
146
147 return (IShellBrowser *) sb;
148}
149
150/***************************************************************************
151* IShellBrowserImpl_QueryInterface
152*/
153HRESULT WINAPI IShellBrowserImpl_QueryInterface(IShellBrowser *iface,
154 REFIID riid,
155 LPVOID *ppvObj)
156{
157 ICOM_THIS(IShellBrowserImpl, iface);
158
159#ifndef __WIN32OS2__
160 TRACE("(%p)\n\t%s\n", This, debugstr_guid(riid));
161#endif
162
163 *ppvObj = NULL;
164
165 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
166 { *ppvObj = This;
167 }
168 else if(IsEqualIID(riid, &IID_IOleWindow)) /*IOleWindow*/
169 { *ppvObj = (IOleWindow*)This;
170 }
171
172 else if(IsEqualIID(riid, &IID_IShellBrowser)) /*IShellBrowser*/
173 { *ppvObj = (IShellBrowser*)This;
174 }
175
176 else if(IsEqualIID(riid, &IID_ICommDlgBrowser)) /*ICommDlgBrowser*/
177 { *ppvObj = (ICommDlgBrowser*) &(This->lpVtblCommDlgBrowser);
178 }
179
180 else if(IsEqualIID(riid, &IID_IServiceProvider)) /* IServiceProvider */
181 { *ppvObj = (ICommDlgBrowser*) &(This->lpVtblServiceProvider);
182 }
183
184 if(*ppvObj)
185 { IUnknown_AddRef( (IShellBrowser*) *ppvObj);
186 return S_OK;
187 }
188 FIXME("Unknown interface requested\n");
189 return E_NOINTERFACE;
190}
191
192/**************************************************************************
193* IShellBrowser::AddRef
194*/
195ULONG WINAPI IShellBrowserImpl_AddRef(IShellBrowser * iface)
196{
197 ICOM_THIS(IShellBrowserImpl, iface);
198
199 TRACE("(%p)\n", This);
200
201 return ++(This->ref);
202}
203
204/**************************************************************************
205* IShellBrowserImpl_Release
206*/
207ULONG WINAPI IShellBrowserImpl_Release(IShellBrowser * iface)
208{
209 ICOM_THIS(IShellBrowserImpl, iface);
210
211 TRACE("(%p)\n", This);
212
213 if (!--(This->ref))
214 {
215 HeapFree(GetProcessHeap(),0, This);
216 return 0;
217 }
218 return This->ref;
219}
220
221/*
222 * IOleWindow
223 */
224
225/**************************************************************************
226* IShellBrowserImpl_GetWindow (IOleWindow)
227*
228* Inherited from IOleWindow::GetWindow
229*
230* See Windows documentation for more details
231*
232* Note : We will never be window less in the File Open dialog
233*
234*/
235HRESULT WINAPI IShellBrowserImpl_GetWindow(IShellBrowser * iface,
236 HWND * phwnd)
237{
238 ICOM_THIS(IShellBrowserImpl, iface);
239
240 TRACE("(%p)\n", This);
241
242 if(!This->hwndOwner)
243 return E_FAIL;
244
245 *phwnd = This->hwndOwner;
246
247 return (*phwnd) ? S_OK : E_UNEXPECTED;
248
249}
250
251/**************************************************************************
252* IShellBrowserImpl_ContextSensitiveHelp
253*/
254HRESULT WINAPI IShellBrowserImpl_ContextSensitiveHelp(IShellBrowser * iface,
255 BOOL fEnterMode)
256{
257 ICOM_THIS(IShellBrowserImpl, iface);
258
259 TRACE("(%p)\n", This);
260
261 /* Feature not implemented */
262 return E_NOTIMPL;
263}
264
265/*
266 * IShellBrowser
267 */
268
269/**************************************************************************
270* IShellBrowserImpl_BrowseObject
271*
272* See Windows documentation on IShellBrowser::BrowseObject for more details
273*
274* This function will override user specified flags and will always
275* use SBSP_DEFBROWSER and SBSP_DEFMODE.
276*/
277HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface,
278 LPCITEMIDLIST pidl,
279 UINT wFlags)
280{
281 HRESULT hRes;
282 IShellFolder *psfTmp;
283 IShellView *psvTmp;
284 FileOpenDlgInfos *fodInfos;
285 LPITEMIDLIST pidlTmp;
286 HWND hwndView;
287 HWND hDlgWnd;
288 BOOL bViewHasFocus;
289
290 ICOM_THIS(IShellBrowserImpl, iface);
291
292 TRACE("(%p)(%p,0x%08x)\n", This, pidl, wFlags);
293
294 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
295
296 /* Format the pidl according to its parameter's category */
297 if(wFlags & SBSP_RELATIVE)
298 {
299
300 /* SBSP_RELATIVE A relative pidl (relative from the current folder) */
301 if(FAILED(hRes = IShellFolder_BindToObject(fodInfos->Shell.FOIShellFolder,
302 pidl, NULL, &IID_IShellFolder, (LPVOID *)&psfTmp)))
303 {
304 ERR("bind to object failed\n");
305 return hRes;
306 }
307 /* create an absolute pidl */
308 pidlTmp = COMDLG32_PIDL_ILCombine(fodInfos->ShellInfos.pidlAbsCurrent,
309 (LPITEMIDLIST)pidl);
310 }
311 else if(wFlags & SBSP_PARENT)
312 {
313 /* Browse the parent folder (ignores the pidl) */
314 pidlTmp = GetParentPidl(fodInfos->ShellInfos.pidlAbsCurrent);
315 psfTmp = GetShellFolderFromPidl(pidlTmp);
316
317 }
318 else /* SBSP_ABSOLUTE is 0x0000 */
319 {
320 /* An absolute pidl (relative from the desktop) */
321 pidlTmp = COMDLG32_PIDL_ILClone((LPITEMIDLIST)pidl);
322 psfTmp = GetShellFolderFromPidl(pidlTmp);
323 }
324
325 if(!psfTmp)
326 {
327 ERR("could not browse to folder\n");
328 return E_FAIL;
329 }
330
331 /* If the pidl to browse to is equal to the actual pidl ...
332 do nothing and pretend you did it*/
333 if(COMDLG32_PIDL_ILIsEqual(pidlTmp,fodInfos->ShellInfos.pidlAbsCurrent))
334 {
335 IShellFolder_Release(psfTmp);
336 COMDLG32_SHFree(pidlTmp);
337 TRACE("keep current folder\n");
338 return NOERROR;
339 }
340
341 /* Release the current DataObject */
342 if (fodInfos->Shell.FOIDataObject)
343 {
344 IDataObject_Release(fodInfos->Shell.FOIDataObject);
345 fodInfos->Shell.FOIDataObject = NULL;
346 }
347
348 /* Create the associated view */
349 TRACE("create view object\n");
350 if(FAILED(hRes = IShellFolder_CreateViewObject(psfTmp, fodInfos->ShellInfos.hwndOwner,
351 &IID_IShellView, (LPVOID *)&psvTmp))) goto error;
352
353 /* Check if listview has focus */
354 bViewHasFocus = IsChild(fodInfos->ShellInfos.hwndView,GetFocus());
355
356 /* Get the foldersettings from the old view */
357 if(fodInfos->Shell.FOIShellView)
358 IShellView_GetCurrentInfo(fodInfos->Shell.FOIShellView, &fodInfos->ShellInfos.folderSettings);
359
360 /* Release the old fodInfos->Shell.FOIShellView and update its value.
361 We have to update this early since ShellView_CreateViewWindow of native
362 shell32 calls OnStateChange and needs the correct view here.*/
363 if(fodInfos->Shell.FOIShellView)
364 {
365 IShellView_DestroyViewWindow(fodInfos->Shell.FOIShellView);
366 IShellView_Release(fodInfos->Shell.FOIShellView);
367 }
368 fodInfos->Shell.FOIShellView = psvTmp;
369
370 /* Release old FOIShellFolder and update its value */
371 if (fodInfos->Shell.FOIShellFolder)
372 IShellFolder_Release(fodInfos->Shell.FOIShellFolder);
373 fodInfos->Shell.FOIShellFolder = psfTmp;
374
375 /* Release old pidlAbsCurrent and update its value */
376 COMDLG32_SHFree((LPVOID)fodInfos->ShellInfos.pidlAbsCurrent);
377 fodInfos->ShellInfos.pidlAbsCurrent = pidlTmp;
378
379 /* Create the window */
380 TRACE("create view window\n");
381 if(FAILED(hRes = IShellView_CreateViewWindow(psvTmp, NULL,
382 &fodInfos->ShellInfos.folderSettings, fodInfos->Shell.FOIShellBrowser,
383 &fodInfos->ShellInfos.rectView, &hwndView))) goto error;
384
385 fodInfos->ShellInfos.hwndView = hwndView;
386
387 /* Select the new folder in the Look In combo box of the Open file dialog */
388 FILEDLG95_LOOKIN_SelectItem(fodInfos->DlgInfos.hwndLookInCB,fodInfos->ShellInfos.pidlAbsCurrent);
389
390 /* changes the tab order of the ListView to reflect the window's File Dialog */
391 hDlgWnd = GetDlgItem(GetParent(hwndView), IDC_LOOKIN);
392 SetWindowPos(hwndView, hDlgWnd, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE);
393
394 /* Since we destroyed the old view if it had focus set focus to the newly created view */
395 if (bViewHasFocus)
396 SetFocus(fodInfos->ShellInfos.hwndView);
397
398 return hRes;
399error:
400 ERR("Failed with error 0x%08lx\n", hRes);
401 return hRes;
402}
403
404/**************************************************************************
405* IShellBrowserImpl_EnableModelessSB
406*/
407HRESULT WINAPI IShellBrowserImpl_EnableModelessSB(IShellBrowser *iface,
408 BOOL fEnable)
409
410{
411 ICOM_THIS(IShellBrowserImpl, iface);
412
413 TRACE("(%p)\n", This);
414
415 /* Feature not implemented */
416 return E_NOTIMPL;
417}
418
419/**************************************************************************
420* IShellBrowserImpl_GetControlWindow
421*/
422HRESULT WINAPI IShellBrowserImpl_GetControlWindow(IShellBrowser *iface,
423 UINT id,
424 HWND *lphwnd)
425
426{
427 ICOM_THIS(IShellBrowserImpl, iface);
428
429 TRACE("(%p)\n", This);
430
431 /* Feature not implemented */
432 return E_NOTIMPL;
433}
434/**************************************************************************
435* IShellBrowserImpl_GetViewStateStream
436*/
437HRESULT WINAPI IShellBrowserImpl_GetViewStateStream(IShellBrowser *iface,
438 DWORD grfMode,
439 LPSTREAM *ppStrm)
440
441{
442 ICOM_THIS(IShellBrowserImpl, iface);
443
444 FIXME("(%p 0x%08lx %p)\n", This, grfMode, ppStrm);
445
446 /* Feature not implemented */
447 return E_NOTIMPL;
448}
449/**************************************************************************
450* IShellBrowserImpl_InsertMenusSB
451*/
452HRESULT WINAPI IShellBrowserImpl_InsertMenusSB(IShellBrowser *iface,
453 HMENU hmenuShared,
454 LPOLEMENUGROUPWIDTHS lpMenuWidths)
455
456{
457 ICOM_THIS(IShellBrowserImpl, iface);
458
459 TRACE("(%p)\n", This);
460
461 /* Feature not implemented */
462 return E_NOTIMPL;
463}
464/**************************************************************************
465* IShellBrowserImpl_OnViewWindowActive
466*/
467HRESULT WINAPI IShellBrowserImpl_OnViewWindowActive(IShellBrowser *iface,
468 IShellView *ppshv)
469
470{
471 ICOM_THIS(IShellBrowserImpl, iface);
472
473 TRACE("(%p)\n", This);
474
475 /* Feature not implemented */
476 return E_NOTIMPL;
477}
478/**************************************************************************
479* IShellBrowserImpl_QueryActiveShellView
480*/
481HRESULT WINAPI IShellBrowserImpl_QueryActiveShellView(IShellBrowser *iface,
482 IShellView **ppshv)
483
484{
485 ICOM_THIS(IShellBrowserImpl, iface);
486
487 FileOpenDlgInfos *fodInfos;
488
489 TRACE("(%p)\n", This);
490
491 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
492
493 if(!(*ppshv = fodInfos->Shell.FOIShellView))
494 {
495 return E_FAIL;
496 }
497 IShellView_AddRef(fodInfos->Shell.FOIShellView);
498 return NOERROR;
499}
500/**************************************************************************
501* IShellBrowserImpl_RemoveMenusSB
502*/
503HRESULT WINAPI IShellBrowserImpl_RemoveMenusSB(IShellBrowser *iface,
504 HMENU hmenuShared)
505
506{
507 ICOM_THIS(IShellBrowserImpl, iface);
508
509 TRACE("(%p)\n", This);
510
511 /* Feature not implemented */
512 return E_NOTIMPL;
513}
514/**************************************************************************
515* IShellBrowserImpl_SendControlMsg
516*/
517HRESULT WINAPI IShellBrowserImpl_SendControlMsg(IShellBrowser *iface,
518 UINT id,
519 UINT uMsg,
520 WPARAM wParam,
521 LPARAM lParam,
522 LRESULT *pret)
523
524{
525 ICOM_THIS(IShellBrowserImpl, iface);
526 LRESULT lres;
527
528 TRACE("(%p)->(0x%08x 0x%08x 0x%08x 0x%08lx %p)\n", This, id, uMsg, wParam, lParam, pret);
529
530 switch (id)
531 {
532 case FCW_TOOLBAR:
533 lres = SendDlgItemMessageA( This->hwndOwner, IDC_TOOLBAR, uMsg, wParam, lParam);
534 break;
535 default:
536 FIXME("ctrl id: %x\n", id);
537 return E_NOTIMPL;
538 }
539 if (pret) *pret = lres;
540 return S_OK;
541}
542/**************************************************************************
543* IShellBrowserImpl_SetMenuSB
544*/
545HRESULT WINAPI IShellBrowserImpl_SetMenuSB(IShellBrowser *iface,
546 HMENU hmenuShared,
547 HOLEMENU holemenuReserved,
548 HWND hwndActiveObject)
549
550{
551 ICOM_THIS(IShellBrowserImpl, iface);
552
553 TRACE("(%p)\n", This);
554
555 /* Feature not implemented */
556 return E_NOTIMPL;
557}
558/**************************************************************************
559* IShellBrowserImpl_SetStatusTextSB
560*/
561HRESULT WINAPI IShellBrowserImpl_SetStatusTextSB(IShellBrowser *iface,
562 LPCOLESTR lpszStatusText)
563
564{
565 ICOM_THIS(IShellBrowserImpl, iface);
566
567 TRACE("(%p)\n", This);
568
569 /* Feature not implemented */
570 return E_NOTIMPL;
571}
572/**************************************************************************
573* IShellBrowserImpl_SetToolbarItems
574*/
575HRESULT WINAPI IShellBrowserImpl_SetToolbarItems(IShellBrowser *iface,
576 LPTBBUTTON lpButtons,
577 UINT nButtons,
578 UINT uFlags)
579
580{
581 ICOM_THIS(IShellBrowserImpl, iface);
582
583 TRACE("(%p)\n", This);
584
585 /* Feature not implemented */
586 return E_NOTIMPL;
587}
588/**************************************************************************
589* IShellBrowserImpl_TranslateAcceleratorSB
590*/
591HRESULT WINAPI IShellBrowserImpl_TranslateAcceleratorSB(IShellBrowser *iface,
592 LPMSG lpmsg,
593 WORD wID)
594
595{
596 ICOM_THIS(IShellBrowserImpl, iface);
597
598 TRACE("(%p)\n", This);
599
600 /* Feature not implemented */
601 return E_NOTIMPL;
602}
603
604static ICOM_VTABLE(IShellBrowser) IShellBrowserImpl_Vtbl =
605{
606 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
607 /* IUnknown */
608 IShellBrowserImpl_QueryInterface,
609 IShellBrowserImpl_AddRef,
610 IShellBrowserImpl_Release,
611 /* IOleWindow */
612 IShellBrowserImpl_GetWindow,
613 IShellBrowserImpl_ContextSensitiveHelp,
614 /* IShellBrowser */
615 IShellBrowserImpl_InsertMenusSB,
616 IShellBrowserImpl_SetMenuSB,
617 IShellBrowserImpl_RemoveMenusSB,
618 IShellBrowserImpl_SetStatusTextSB,
619 IShellBrowserImpl_EnableModelessSB,
620 IShellBrowserImpl_TranslateAcceleratorSB,
621 IShellBrowserImpl_BrowseObject,
622 IShellBrowserImpl_GetViewStateStream,
623 IShellBrowserImpl_GetControlWindow,
624 IShellBrowserImpl_SendControlMsg,
625 IShellBrowserImpl_QueryActiveShellView,
626 IShellBrowserImpl_OnViewWindowActive,
627 IShellBrowserImpl_SetToolbarItems
628};
629
630
631
632/*
633 * ICommDlgBrowser
634 */
635
636/***************************************************************************
637* IShellBrowserImpl_ICommDlgBrowser_QueryInterface
638*/
639HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_QueryInterface(
640 ICommDlgBrowser *iface,
641 REFIID riid,
642 LPVOID *ppvObj)
643{
644 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
645
646 TRACE("(%p)\n", This);
647
648 return IShellBrowserImpl_QueryInterface(This,riid,ppvObj);
649}
650
651/**************************************************************************
652* IShellBrowserImpl_ICommDlgBrowser_AddRef
653*/
654ULONG WINAPI IShellBrowserImpl_ICommDlgBrowser_AddRef(ICommDlgBrowser * iface)
655{
656 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
657
658 TRACE("(%p)\n", This);
659
660 return IShellBrowserImpl_AddRef(This);
661}
662
663/**************************************************************************
664* IShellBrowserImpl_ICommDlgBrowser_Release
665*/
666ULONG WINAPI IShellBrowserImpl_ICommDlgBrowser_Release(ICommDlgBrowser * iface)
667{
668 _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface);
669
670 TRACE("(%p)\n", This);
671
672 return IShellBrowserImpl_Release(This);
673}
674/**************************************************************************
675* IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand
676*
677* Called when a user double-clicks in the view or presses the ENTER key
678*/
679HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand(ICommDlgBrowser *iface,
680 IShellView *ppshv)
681{
682 LPITEMIDLIST pidl;
683 FileOpenDlgInfos *fodInfos;
684
685 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
686
687 TRACE("(%p)\n", This);
688
689 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
690
691 /* If the selected object is not a folder, send a IDOK command to parent window */
692 if((pidl = GetPidlFromDataObject(fodInfos->Shell.FOIDataObject, 1)))
693 {
694 HRESULT hRes;
695
696 ULONG ulAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER;
697 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr);
698 if (ulAttr & (SFGAO_FOLDER | SFGAO_HASSUBFOLDER) )
699 {
700 hRes = IShellBrowser_BrowseObject((IShellBrowser *)This,pidl,SBSP_RELATIVE);
701 }
702 else
703 {
704 /* Tell the dialog that the user selected a file */
705 hRes = PostMessageA(This->hwndOwner, WM_COMMAND, IDOK, 0L);
706 }
707
708 /* Free memory used by pidl */
709 COMDLG32_SHFree((LPVOID)pidl);
710
711 return hRes;
712 }
713
714 return E_FAIL;
715}
716
717/**************************************************************************
718* IShellBrowserImpl_ICommDlgBrowser_OnStateChange
719*/
720HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnStateChange(ICommDlgBrowser *iface,
721 IShellView *ppshv,
722 ULONG uChange)
723{
724
725 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
726
727 TRACE("(%p shv=%p)\n", This, ppshv);
728
729 switch (uChange)
730 {
731 case CDBOSC_SETFOCUS:
732 /* FIXME: Reset the default button.
733 This should be taken care of by defdlg. If control
734 other than button receives focus the default button
735 should be restored. */
736 SendMessageA(This->hwndOwner, DM_SETDEFID, IDOK, 0);
737
738 break;
739 case CDBOSC_KILLFOCUS:
740 {
741 FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
742 if(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
743 SetDlgItemTextA(fodInfos->ShellInfos.hwndOwner,IDOK,"&Save");
744 }
745 break;
746 case CDBOSC_SELCHANGE:
747 return IShellBrowserImpl_ICommDlgBrowser_OnSelChange(iface,ppshv);
748 case CDBOSC_RENAME:
749 /* nothing to do */
750 break;
751 }
752
753 return NOERROR;
754}
755
756/**************************************************************************
757* IShellBrowserImpl_ICommDlgBrowser_IncludeObject
758*/
759HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser *iface,
760 IShellView * ppshv,
761 LPCITEMIDLIST pidl)
762{
763 FileOpenDlgInfos *fodInfos;
764 ULONG ulAttr;
765 STRRET str;
766 WCHAR szPathW[MAX_PATH];
767
768 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
769
770 TRACE("(%p)\n", This);
771
772 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
773
774 ulAttr = SFGAO_HIDDEN | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR | SFGAO_LINK;
775 IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr);
776
777 if( (ulAttr & SFGAO_HIDDEN) /* hidden */
778 | !(ulAttr & (SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR))) /* special folder */
779 return S_FALSE;
780
781 /* always include directorys and links */
782 if(ulAttr & (SFGAO_FOLDER | SFGAO_LINK))
783 return S_OK;
784
785 /* Check if there is a mask to apply if not */
786 if(!fodInfos->ShellInfos.lpstrCurrentFilter || !lstrlenW(fodInfos->ShellInfos.lpstrCurrentFilter))
787 return S_OK;
788
789 if (SUCCEEDED(IShellFolder_GetDisplayNameOf(fodInfos->Shell.FOIShellFolder, pidl, SHGDN_INFOLDER | SHGDN_FORPARSING, &str)))
790 {
791 if (SUCCEEDED(COMDLG32_StrRetToStrNW(szPathW, MAX_PATH, &str, pidl)))
792 {
793 if (COMDLG32_PathMatchSpecW(szPathW, fodInfos->ShellInfos.lpstrCurrentFilter))
794 return S_OK;
795 }
796 }
797 return S_FALSE;
798
799}
800
801/**************************************************************************
802* IShellBrowserImpl_ICommDlgBrowser_OnSelChange
803*/
804HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IShellView *ppshv)
805{
806 FileOpenDlgInfos *fodInfos;
807
808 _ICOM_THIS_FromICommDlgBrowser(IShellBrowserImpl,iface);
809
810 fodInfos = (FileOpenDlgInfos *) GetPropA(This->hwndOwner,FileOpenDlgInfosStr);
811 TRACE("(%p do=%p view=%p)\n", This, fodInfos->Shell.FOIDataObject, fodInfos->Shell.FOIShellView);
812
813 /* release old selections */
814 if (fodInfos->Shell.FOIDataObject)
815 IDataObject_Release(fodInfos->Shell.FOIDataObject);
816
817 /* get a new DataObject from the ShellView */
818 if(FAILED(IShellView_GetItemObject(fodInfos->Shell.FOIShellView, SVGIO_SELECTION,
819 &IID_IDataObject, (LPVOID*)&fodInfos->Shell.FOIDataObject)))
820 return E_FAIL;
821
822 FILEDLG95_FILENAME_FillFromSelection(This->hwndOwner);
823
824 SendCustomDlgNotificationMessage(This->hwndOwner, CDN_SELCHANGE);
825 return S_OK;
826}
827
828static ICOM_VTABLE(ICommDlgBrowser) IShellBrowserImpl_ICommDlgBrowser_Vtbl =
829{
830 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
831 /* IUnknown */
832 IShellBrowserImpl_ICommDlgBrowser_QueryInterface,
833 IShellBrowserImpl_ICommDlgBrowser_AddRef,
834 IShellBrowserImpl_ICommDlgBrowser_Release,
835 /* ICommDlgBrowser */
836 IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand,
837 IShellBrowserImpl_ICommDlgBrowser_OnStateChange,
838 IShellBrowserImpl_ICommDlgBrowser_IncludeObject
839};
840
841
842
843
844/*
845 * IServiceProvider
846 */
847
848/***************************************************************************
849* IShellBrowserImpl_IServiceProvider_QueryInterface
850*/
851HRESULT WINAPI IShellBrowserImpl_IServiceProvider_QueryInterface(
852 IServiceProvider *iface,
853 REFIID riid,
854 LPVOID *ppvObj)
855{
856 _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
857
858 FIXME("(%p)\n", This);
859
860 return IShellBrowserImpl_QueryInterface(This,riid,ppvObj);
861}
862
863/**************************************************************************
864* IShellBrowserImpl_IServiceProvider_AddRef
865*/
866ULONG WINAPI IShellBrowserImpl_IServiceProvider_AddRef(IServiceProvider * iface)
867{
868 _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
869
870 FIXME("(%p)\n", This);
871
872 return IShellBrowserImpl_AddRef(This);
873}
874
875/**************************************************************************
876* IShellBrowserImpl_IServiceProvider_Release
877*/
878ULONG WINAPI IShellBrowserImpl_IServiceProvider_Release(IServiceProvider * iface)
879{
880 _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
881
882 FIXME("(%p)\n", This);
883
884 return IShellBrowserImpl_Release(This);
885}
886
887/**************************************************************************
888* IShellBrowserImpl_IServiceProvider_Release
889*
890* NOTES
891* the w2k shellview asks for
892* guidService = SID_STopLevelBrowser
893* riid = IShellBrowser
894*
895* FIXME
896* this is a hack!
897*/
898
899HRESULT WINAPI IShellBrowserImpl_IServiceProvider_QueryService(
900 IServiceProvider * iface,
901 REFGUID guidService,
902 REFIID riid,
903 void** ppv)
904{
905 _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface);
906
907#ifndef __WIN32OS2__
908 FIXME("(%p)\n\t%s\n\t%s\n", This,debugstr_guid(guidService), debugstr_guid(riid) );
909#endif
910
911 *ppv = NULL;
912 if(guidService && IsEqualIID(guidService, &SID_STopLevelBrowser))
913 {
914 return IShellBrowserImpl_QueryInterface(This,riid,ppv);
915 }
916 FIXME("(%p) unknown interface requested\n", This);
917 return E_NOINTERFACE;
918
919}
920
921static ICOM_VTABLE(IServiceProvider) IShellBrowserImpl_IServiceProvider_Vtbl =
922{
923 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
924 /* IUnknown */
925 IShellBrowserImpl_IServiceProvider_QueryInterface,
926 IShellBrowserImpl_IServiceProvider_AddRef,
927 IShellBrowserImpl_IServiceProvider_Release,
928 /* IServiceProvider */
929 IShellBrowserImpl_IServiceProvider_QueryService
930};
Note: See TracBrowser for help on using the repository browser.