Alaska Software Inc. - Re: Folder Selection
Username: Password:
AuthorTopic: Re: Folder Selection
Andreas Gehrs-Pahl

View the complete thread for this message in:

Re: Folder Selection
on Wed, 30 Sep 2015 15:22:33 -0400
Carlos,

>I am trying to use it but it is giving an error.

This code is based on something that was originally posted by Steffen Rassek 
on 10/05/2001 (and again 11/22/2001) in the "public.xbase++.gui" News Group.

Joe Carrick also posted this as his "MxBrowseForFolder" in various NGs, 
including: "public.xbase++.generic", on 06/23/2004, 09/26/2005, 08/26/2009, 
03/09/2010, and in "public.xbase++.gui" on 07/20/2004, 01/11/2005.

It was also re-posted in various, usually slightly modified and sometimes 
incomplete versions, by several other users, including Pascal Boivin on 
01/09/2013 in the "public.xbase++.generic" NG, which is the code that you 
apparently used as your starting point.

The following line of code is the reason for the IDSC that you are getting 
with your version:

Line 52: BaStruct(aOFN, NIL)         pidlRoot

Changing that line to:

Line 52: BaStruct(aOFN, 0)           pidlRoot

will fix the problem. The original code in Pascal's version was:

Line 46: BaStruct(aOFN, NULL)        pidlRoot

But "NULL" wasn't #defined (as 0 [Zero]) anywhere in Steffen's or Pascal's 
versions, even though Joe's code usually included that define constant, so 
you apparently changed NULL to NIL instead of 0, which is the reason for 
the memory corruption that you will get with your code.

Also, Günter Beyes has posted a more comprehensive version of this function, 
which doesn't use BAP and lets you (supposedly) even select a random start 
directory value other than NULL (or the CSIDL_* constants) for pidlRoot, so 
it might be superior to the other, BAP-based versions, even though this 
actually never worked for me. You can find this demo program in the GUI NG 
in a thread with a subject of: "Window api call", in a post that is dated: 
01/11/2005.

There is also an OT4Xb (demo) version available, which uses a callback and 
definitely lets you select a random directory as (pre-selected) root. It was 
posted by Pablo Botella on 03/10/2010 in the "public.xbase++.generic" NG in 
a thread with the subject: "FolderBrowse".

Hope that helps,

Andreas

Andreas Gehrs-Pahl
Absolute Software, LLC

phone: (989) 723-9927
email: Andreas.GP@Charter.net
web:   http://www.Aerospace-History.net