Update of /cvsroot/audacity/lib-src/FileDialog/win
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv27822
Modified Files:
FileDialogPrivate.cpp FileDialogPrivate.h
Log Message:
Fix for NULL PIDL on Vista...can't believe nobody noticed this before...thanks
to Andre.
Index: FileDialogPrivate.h
===================================================================
RCS file: /cvsroot/audacity/lib-src/FileDialog/win/FileDialogPrivate.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- FileDialogPrivate.h 24 May 2008 02:57:39 -0000 1.5
+++ FileDialogPrivate.h 11 Apr 2009 05:53:09 -0000 1.6
@@ -41,7 +41,7 @@
virtual void EnableButton(wxString label, fdCallback cb, void *cbdata);
virtual void ClickButton(int index);
- virtual void FilterFiles(HWND hDlg);
+ virtual void FilterFiles(HWND hDlg, bool refresh);
virtual void ParseFilter(int index);
wxString m_buttonlabel;
Index: FileDialogPrivate.cpp
===================================================================
RCS file: /cvsroot/audacity/lib-src/FileDialog/win/FileDialogPrivate.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- FileDialogPrivate.cpp 1 Mar 2009 19:13:25 -0000 1.15
+++ FileDialogPrivate.cpp 11 Apr 2009 05:53:09 -0000 1.16
@@ -228,18 +228,16 @@
{
OPENFILENAME *ofn = (OPENFILENAME *)
GetWindowLongPtr(hDlg, GWLP_USERDATA);
- FileDialog *me = (FileDialog *)
- ofn->lCustData;
- me->FilterFiles(hDlg);
+ FileDialog *me = (FileDialog *) ofn->lCustData;
+ me->FilterFiles(hDlg, false);
}
else if (CDN_TYPECHANGE == (pNotifyCode->hdr).code)
{
OPENFILENAME *ofn = (OPENFILENAME *)
GetWindowLongPtr(hDlg, GWLP_USERDATA);
- FileDialog *me = (FileDialog *)
- ofn->lCustData;
+ FileDialog *me = (FileDialog *) ofn->lCustData;
me->ParseFilter(ofn->nFilterIndex);
- me->FilterFiles(hDlg);
+ me->FilterFiles(hDlg, true);
}
break;
}
@@ -249,10 +247,15 @@
return 0;
}
-void FileDialog::FilterFiles(HWND hDlg)
+#define WM_GETISHELLBROWSER WM_USER + 7
+
+void FileDialog::FilterFiles(HWND hDlg, bool refresh)
{
HWND parent = ::GetParent(hDlg);
IShellFolder *ishell = NULL;
+ IShellBrowser *ishellbrowser = NULL; // Does not have to be released
+ IShellView *ishellview = NULL;
+ IFolderView *ifolderview = NULL;
LPMALLOC imalloc = NULL;
HRESULT hr;
@@ -271,13 +274,25 @@
wxASSERT((hr == NOERROR) && (imalloc != NULL));
return;
}
-
+
+ // Get IShellBrowser interface for current dialog
+ ishellbrowser = (IShellBrowser*)::SendMessage(parent, WM_GETISHELLBROWSER,
0, 0);
+ if (ishellbrowser)
+ {
+ // Get IShellBrowser interface for returned browser
+ if (ishellbrowser->QueryActiveShellView(&ishellview) == S_OK)
+ {
+ // Get the IFolderView interface...available on XP or greater
+ ishellview->QueryInterface(IID_IFolderView, (void **)&ifolderview);
+ }
+ }
+
// Init
LVITEM lvi;
wxZeroMemory(lvi);
-
+
// Process all items
- int fltcnt = m_Filters.GetCount();
+ int fltcnt = (int) m_Filters.GetCount();
int itmcnt = ::SendMessage(lv, LVM_GETITEMCOUNT, 0, 0);
for (int itm = 0; itm < itmcnt; itm++)
{
@@ -289,8 +304,24 @@
wxASSERT(FALSE);
break;
}
+
LPCITEMIDLIST fidl = (LPCITEMIDLIST) lvi.lParam;
-
+
+ // On Vista, lParam no longer contains the pidl so retrieve it via the
+ // IFolderView interface. This interface is only available on XP or
higher
+ // so if that limitation isn't workable, use IShellView::GetItemObject()
to
+ // retrieve items.
+ if (fidl == NULL && ifolderview != NULL)
+ {
+ ifolderview->Item(itm, (LPITEMIDLIST *) &fidl);
+ }
+
+ if (fidl == NULL)
+ {
+ wxASSERT(fidl != NULL);
+ break;
+ }
+
// Retrieve the IShellFolder interface of the parent (must be
Release()'d)
if (ishell == NULL)
{
@@ -370,9 +401,28 @@
itmcnt--;
}
}
-
-done:
-
+
+ // On Vista and maybe XP, we seem to need to refresh the view after
+ // changing the filters. But, only refresh for type changes and not
+ // selection changes since it causes additional selection change
+ // events to occur.
+ if (ishellview && refresh)
+ {
+ ishellview->Refresh();
+ }
+
+ // Release the interface
+ if (ifolderview)
+ {
+ ifolderview->Release();
+ }
+
+ // Release the interface
+ if (ishellview)
+ {
+ ishellview->Release();
+ }
+
// Release the interface
if (ishell)
{
------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs