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

Last change on this file since 6688 was 6645, checked in by bird, 24 years ago

Added $Id:$ keyword.

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