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

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

Merged with latest Wine version (Wine 20001002 level (10-21-2000))

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