Click here to Skip to main content
16,011,839 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Sockets problem - figured it out Pin
Nish Nishant13-Nov-01 22:19
sitebuilderNish Nishant13-Nov-01 22:19 
QuestionHow to Browse for a Directory? Pin
Jerry Wang13-Nov-01 14:20
Jerry Wang13-Nov-01 14:20 
AnswerRe: How to Browse for a Directory? Pin
Michael Dunn13-Nov-01 16:09
sitebuilderMichael Dunn13-Nov-01 16:09 
GeneralRe: How to Browse for a Directory? Pin
PJ Arends13-Nov-01 17:13
professionalPJ Arends13-Nov-01 17:13 
GeneralRe: How to Browse for a Directory? Pin
Michael Dunn13-Nov-01 20:18
sitebuilderMichael Dunn13-Nov-01 20:18 
GeneralRe: How to Browse for a Directory? Pin
Mark Terrano16-Nov-01 12:24
Mark Terrano16-Nov-01 12:24 
Generala base question Pin
13-Nov-01 13:42
suss13-Nov-01 13:42 
GeneralSHGetPathFromID under WinXP vs Win2000 Pin
Mark Terrano13-Nov-01 12:05
Mark Terrano13-Nov-01 12:05 
Problem:
Code working for a long time under WinME/2000/98 does not work under WinXP. Little function to pop up a dialog box and allow the user to pick a folder (or file) which is returned as a CString. I get back the wrong value if user creates new folder or types non-existing folder into box.

What I'm looking for:
Function to pop up dialog and get back existing or new folder as specified by user.

Symptoms:
Works just as I would expect it to under Win98/ME/2000.

Under WinXP if the user creates a folder, or types a new folder into the edit box I get back a reference to their user directory. (Please excuse a bit of 'debugging mess' I'm still trying to figure out what is going on).

Also, there are some header files that I don't have the latest versions of, being limited to VC6 with all patches (so you can ignore my comments about BIF_USENEWUI - which is documented but appears at some later point I think).

I didn't see any KB articles related to WinXP for either of my two functions-in-question.
Any help would be appreciated!
--Mark

-----My Test Code------

CString CXpgetfoldercheckDlg::getFolderName(CString title, bool requireTrailingBackslash, bool allowNewFolders)
{
// PURPOSE:
// Uses latest UI to get a folder name.
// PARAMS:
// title = the title of the browse dialog.
// rquireTrailingBackslash = true if you want the last character of the folder to be '\' (default t)
// allowNewFolders = true if you want a 'new' button to appear on the dialog (default t)
// RETURNS:
// valid folder name if successful or NULL if not
// REQUIRED:
// IE 5.0 on up, or Win2000 on up
// STEPS:
// Bring up a common file dialog,
// Allow the user's to select a folder name
// Close the dialog
//
// KNOWN BUG: Problem with WindowXP (11-2-2001) - typed-in filename (i.e. new file name) returns the
// user's mydocuments folder.
// Results with the following settings
// info.ulFlags = BIF_RETURNONLYFSDIRS | BIF_EDITBOX;
BROWSEINFO info;
ITEMIDLIST *list;
HRESULT ret;

DWORD dwCoInit=COINIT_APARTMENTTHREADED;
ret = CoInitializeEx(NULL,dwCoInit);
if (ret == S_OK || ret == S_FALSE )
TRACE("CoInitted\n");
else
{
return "ERR: Failed CoInit";
}

//info.ulFlags = BIF_RETURNONLYFSDIRS | BIF_USENEWUI ; //new
// Where are these?
// BIF_USENEWUI
// BIF_NEWDIALOGSTYLE
//FIXME: Could not get the various header issues to work, so I just added the param values for the
//reqd. params above. Docs are correct, could not get them to appear. Will work with IE5.0+ versions.
info.hwndOwner = NULL;
info.lpszTitle = title;
info.lpfn = NULL;
info.pidlRoot = NULL;
info.lParam = 0L;
info.iImage= NULL;
info.pszDisplayName = NULL;
if (allowNewFolders)
{
info.ulFlags = 0x0040 | BIF_EDITBOX;
//info.ulFlags = BIF_RETURNONLYFSDIRS | BIF_EDITBOX;
//info.ulFlags = BIF_RETURNONLYFSDIRS | 0x0040 | BIF_EDITBOX;
//info.ulFlags = BIF_RETURNONLYFSDIRS | BIF_EDITBOX | BIF_STATUSTEXT ;
//info.ulFlags = BIF_RETURNONLYFSDIRS | 0x0040 | BIF_EDITBOX;
}
else
{
info.ulFlags = BIF_RETURNONLYFSDIRS;
}


list = SHBrowseForFolder( &info );
if (list == NULL)
{
//User hit cancel
AfxMessageBox("User cancelled");
return "ERR: User Cancelled";
}

CString fileName;
char buf[MAX_PATH+1];
buf[0]='\0';

ret = SHGetPathFromIDList( list, buf );
if (!ret)
{
return("ERR:Failed to get path from IDList");
}
else
{
fileName = buf;
}


#ifdef _DEBUG
TRACE1("getFolderName] User folder: %s\n", buf);
#endif

//Could still be invalid return - i.e. spaces.
if (fileName.IsEmpty())
return fileName;

// For most uses, I require a trailing \ at the end of the filename. If it is not
// there, then it is appended.
if (requireTrailingBackslash)
if (fileName.Right(1) != "\\")
fileName += "\\";

return fileName;
}


--Mark Terrano

Generalhardware access Pin
13-Nov-01 10:52
suss13-Nov-01 10:52 
GeneralRe: hardware access Pin
Mark Terrano16-Nov-01 12:21
Mark Terrano16-Nov-01 12:21 
GeneralIterate through registry key Pin
Christian Graus13-Nov-01 9:57
protectorChristian Graus13-Nov-01 9:57 
GeneralRe: Iterate through registry key Pin
Tomasz Sowinski13-Nov-01 10:13
Tomasz Sowinski13-Nov-01 10:13 
GeneralCreating a DIB from HANDLE not DDB Pin
Chambers13-Nov-01 7:55
Chambers13-Nov-01 7:55 
GeneralRe: Creating a DIB from HANDLE not DDB Pin
Chris Losinger13-Nov-01 8:41
professionalChris Losinger13-Nov-01 8:41 
GeneralRe: Creating a DIB from HANDLE not DDB Pin
Chambers14-Nov-01 2:52
Chambers14-Nov-01 2:52 
GeneralRe: Creating a DIB from HANDLE not DDB Pin
Chris Losinger14-Nov-01 4:54
professionalChris Losinger14-Nov-01 4:54 
GeneralRS232 Comms with WideTrack Pin
13-Nov-01 7:25
suss13-Nov-01 7:25 
GeneralRe: RS232 Comms with WideTrack Pin
Joaquín M López Muñoz13-Nov-01 8:41
Joaquín M López Muñoz13-Nov-01 8:41 
GeneralRe: RS232 Comms with WideTrack Pin
Mark Terrano16-Nov-01 12:18
Mark Terrano16-Nov-01 12:18 
GeneralPlease help !!! Pin
13-Nov-01 7:18
suss13-Nov-01 7:18 
GeneralRe: Please help !!! Pin
Christian Graus13-Nov-01 8:56
protectorChristian Graus13-Nov-01 8:56 
GeneralRe: Please help !!! Pin
13-Nov-01 10:36
suss13-Nov-01 10:36 
GeneralRe: Please help !!! Pin
Tomasz Sowinski13-Nov-01 10:44
Tomasz Sowinski13-Nov-01 10:44 
GeneralRe: Please help !!! Pin
13-Nov-01 16:22
suss13-Nov-01 16:22 
GeneralRe: Please help !!! Pin
Tomasz Sowinski13-Nov-01 22:24
Tomasz Sowinski13-Nov-01 22:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.