shetlandbob
Programmer
Hello,
I'm using the SHBrowseForFolder dialog to enable the user to select a dir, this works and I've included the code below. (if user selects ok then dir is set into CString resultsDir).
The problem I'm having is getting it to open at a default directory, I understand you have to use the callback function
However when I include the commented out lines above (i.e.)
this it wont compile, it complains with the following::
I've looked on MSDN and through forums etc..... but as far as I can see this is the way to do it?? Any ideas what I'm doing wrong???
I'm using the SHBrowseForFolder dialog to enable the user to select a dir, this works and I've included the code below. (if user selects ok then dir is set into CString resultsDir).
Code:
void CMyDlg::OnFileSetpath()
{
BROWSEINFO bi;
LPMALLOC pMalloc = NULL;
LPITEMIDLIST pidl;
char acStr[MAX_PATH];
if ( SHGetMalloc ( &pMalloc) != NOERROR ) return;
ZeroMemory ( &bi, sizeof ( BROWSEINFO ));
bi.pidlRoot = NULL;
bi.pszDisplayName = acStr;
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_RETURNFSANCESTORS | BIF_USENEWUI;
bi.lpszTitle = "Please Select Directory";
[COLOR=green]// bi.lpfn = BrowseCallBackProc;
[/color]
if ( pidl = SHBrowseForFolder ( &bi ))
{
if ( SHGetPathFromIDList ( pidl, acStr )) resultsDir.Format ( "%s", acStr );
pMalloc->Free (pidl);
}
if ( pMalloc ) pMalloc->Release();
}
The problem I'm having is getting it to open at a default directory, I understand you have to use the callback function
Code:
int CALLBACK BrowseCallBackProc( HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
{
switch(uMsg)
{
case BFFM_INITIALIZED:
::SendMessage( hwnd, BFFM_SETSELECTION, TRUE, lpData );
break;
}
return 0;
}
However when I include the commented out lines above (i.e.)
Code:
bi.lpfn = BrowseCallBackProc;
Code:
MenuInput.cpp(32) : error C2440: '=' : cannot convert from 'int (__stdcall CTPP9Dlg::* )(HWND,UINT,LPARAM,LPARAM)' to 'BFFCALLBACK'
There is no context in which this conversion is possible
I've looked on MSDN and through forums etc..... but as far as I can see this is the way to do it?? Any ideas what I'm doing wrong???