PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: David Kenny on July 22, 2014, 06:59:51 PM

Title: FF_BrowseForFolder & ShlObj.inc
Post by: David Kenny on July 22, 2014, 06:59:51 PM
FF automatically manually defines parts of ShlObj.inc when FF_BrowseForFolder is used in a project.

That causes lots of errors if you actually have a need to include ShlObj.inc.  I am working around it by manually defining the things I need from that file also.
Title: Re: FF_BrowseForFolder & ShlObj.inc
Post by: Paul Squires on July 23, 2014, 08:28:49 AM
Hi David,

Yes, when FF_BrowseForFolder is used *and* the minimum OS specified is Win2000 then FF will generate code that could cause a conflict in your situation. If the minimum OS specified is higher than Win2000 then FF simply #INCLUDEs ShlObj.inc.

I had to do this in a very early version of FF due to the fact that a couple of customers still required Win2000 support. At that time, if I simply #INCLUDEd ShlObj.inc then compiling would fail because some aspects of that Include file were not compatible with Win2000 (some of the api's did not exist on that platform if I remember correctly).

Title: Re: FF_BrowseForFolder & ShlObj.inc
Post by: David Kenny on July 23, 2014, 02:21:42 PM
Hello Paul,

I saw your comments in the declarations setting up FF_BrowseForFolder and tried as you suggested already.  I just went back and tried it again to make sure.  I only tried Win7 as the minimum OS, But BFF and ShlObj.inc don't get along in either case.

It may be that you tested it with PB includes and it worked until switching to Jose's includes?
Title: Re: FF_BrowseForFolder & ShlObj.inc
Post by: Paul Squires on July 23, 2014, 03:50:34 PM
You may be right, it's been a long time since that code was put into FF....  :)

As an alternative, you could try Jose's version afxBrowseForFolder. It probably plays better with FF at this time(?):

FUNCTION AfxBrowseForFolder ( -
   BYVAL hwnd AS DWORD, _
   BYVAL bstrTitle AS WSTRING, _
   OPTIONAL BYVAL startFolder AS WSTRING, _
   OPTIONAL BYVAL dwFlags AS DWORD _
   ) AS WSTRING

Title: Re: FF_BrowseForFolder & ShlObj.inc
Post by: David Kenny on July 23, 2014, 05:26:15 PM
QuoteAs an alternative, you could try Jose's version afxBrowseForFolder.

Good tip!  Like I had said, I had a workaround.  Only mentioning it here so it can go in your bug tracker.  ;)
Title: Re: FF_BrowseForFolder & ShlObj.inc
Post by: David Kenny on July 23, 2014, 07:53:35 PM
QuoteOnly mentioning it here so it can go in your bug tracker.
Please excuse my ignorance.  I had assumed FF was adding the declarations.  They are in fact added by the FF_BrowseForFolder entry in the Functions Library. 

I changed my copy of FF_BrowseForFolder.inc to this:
'[NAME] FF_BrowseForFolder
'[AUTHORNAME]From Jose's includes
'[EMAIL]
'[WEBSITE]
'[VERSION]
'[ISFAVORITE] No
'[EXPAND] No
'[ISPROTOTYPE] No
'[KEYWORDS]
' browse folder
'[/KEYWORDS]
'[DESCRIPTION]
'   Creates and displays a "Browse for Folder" dialog and allows the
'   user to choose the folder.
'
'   hWnd:         Handle of parent window (if any)
'   Caption:      Caption to display as the Title of the dialog.
'   InitialDir:   The initial directory that the dialog will show. If this
'                 value is null then the current directory is used.
'
'
'   Returns:      Name of selected folder (directory)
'
'
'[/DESCRIPTION]
'[CODESTART]

#INCLUDE ONCE "ShlObj.inc" 
#INCLUDE ONCE "AfxShell.inc" 
Function FF_BrowseForFolder( ByVal hWnd As Dword, _
                             ByVal Caption As WString, _
                             ByVal InitialDir As WString _
                             ) As String
                             
    Local UFlags    as Dword

    uFlags = %BIF_NEWDIALOGSTYLE Or %BIF_RETURNONLYFSDIRS Or %BIF_DONTGOBELOWDOMAIN Or %BIF_RETURNFSANCESTORS Or %BIF_USENEWUI
    Function = AfxBrowseForFolder(hWnd, Caption, InitialDir, uFlags)

End Function


Now everything works as it should.

I respectfully retract my inference to a bug in FF.  :-[