Update of /cvsroot/audacity/lib-src/FileDialog/win
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv32399
Modified Files:
FileDialogPrivate.cpp
Log Message:
Make it work on Windows 98 again.
Index: FileDialogPrivate.cpp
===================================================================
RCS file: /cvsroot/audacity/lib-src/FileDialog/win/FileDialogPrivate.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- FileDialogPrivate.cpp 17 Oct 2008 10:14:24 -0000 1.13
+++ FileDialogPrivate.cpp 8 Nov 2008 21:00:26 -0000 1.14
@@ -82,6 +82,76 @@
IMPLEMENT_CLASS(FileDialog, wxFileDialogBase)
// ----------------------------------------------------------------------------
+// Alternative implementation for SHBindToParent() since older
+// shell32.dll version do not supply it.
+//
+// By [EMAIL PROTECTED]
+// http://www.geocities.com/SiliconValley/2060/
+// ----------------------------------------------------------------------------
+
+#include <ShlObj.h>
+#include <ComDef.h>
+
+HRESULT SHBindToParentLocal(
+ LPCITEMIDLIST pidl,
+ REFIID riid,
+ VOID** ppv,
+ LPCITEMIDLIST* ppidlLast)
+{
+ if (!ppv)
+ return E_POINTER;
+
+ // There must be at least one item ID.
+ if (!pidl || !pidl->mkid.cb)
+ return E_INVALIDARG;
+
+ // Get the root folder.
+ IShellFolderPtr desktop;
+ HRESULT hr = SHGetDesktopFolder(&desktop);
+ if (FAILED(hr))
+ return hr;
+
+ // Walk to the penultimate item ID.
+ LPCITEMIDLIST marker = pidl;
+ for (;;)
+ {
+ LPCITEMIDLIST next = reinterpret_cast<LPCITEMIDLIST>(
+ marker->mkid.abID - sizeof(marker->mkid.cb) + marker->mkid.cb);
+ if (!next->mkid.cb)
+ break;
+ marker = next;
+ };
+
+ if (marker == pidl)
+ {
+ // There was only a single item ID, so bind to the root folder.
+ hr = desktop->QueryInterface(riid, ppv);
+ }
+ else
+ {
+ // Copy the ID list, truncating the last item.
+ int length = marker->mkid.abID - pidl->mkid.abID;
+ if (LPITEMIDLIST parent_id = reinterpret_cast<LPITEMIDLIST>(
+ malloc(length + sizeof(pidl->mkid.cb))))
+ {
+ LPBYTE raw_data = reinterpret_cast<LPBYTE>(parent_id);
+ memcpy(raw_data, pidl, length);
+ memset(raw_data + length, 0, sizeof(pidl->mkid.cb));
+ hr = desktop->BindToObject(parent_id, 0, riid, ppv);
+ free(parent_id);
+ }
+ else
+ return E_OUTOFMEMORY;
+ }
+
+ // Return a pointer to the last item ID.
+ if (ppidlLast)
+ *ppidlLast = marker;
+
+ return hr;
+}
+
+// ----------------------------------------------------------------------------
// hook function for moving the dialog
// ----------------------------------------------------------------------------
@@ -224,7 +294,7 @@
// Retrieve the IShellFolder interface of the parent (must be
Release()'d)
if (ishell == NULL)
{
- hr = SHBindToParent(fidl, IID_IShellFolder, (void **)&ishell, NULL);
+ hr = SHBindToParentLocal(fidl, IID_IShellFolder, (void **)&ishell,
NULL);
if (!SUCCEEDED(hr))
{
wxASSERT(SUCCEEDED(hr));
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs