its quite good thing to have in once software lib.
ReplyOriginally posted by: Michael Shamgar
Im using 'SHBrowseForFolder', and have managed to work around all the issues with it, except for one :
I have two 'removable drives' (actually drives that map to my flash card reader, for my digital camera).
Everytime the dialog opens, or attempts to scroll up/down near these drives, it tries to access them, but can't - because there are no devices in them. As a result it pops up the classic :
'There is no disk in the drive. Please insert a disk..'
Cancel/TryAgain/Continue
(etc..)
has anyone come across this, or have a solution for fixing it?
Mike
Originally posted by: Paul Marston
I recently had to write part of an application that would accept an addition of relative paths to an existing directory under win NT 4.
Unfortunately, the SHCreateDirectoryEx is unavailable to NT (only 2K and above :<)
The way I got around this, was to simply break the directory string down (using CString [x]), and analysing if there was a \ or // or . etc.
This meant that I could use a simple if else chain to analyse whether or not the relative path should be added or removed.
For example:
user Path ..\Fred
Existing path D:\Bod\app.exe
became D:\Fred\app.exe
It is clunky, and I am sure that there are hundreds of holes in it, but it works on NT !
More importantly, it is fairly straightforward to do...
ReplyOriginally posted by: bennyfan
Yeah, it's very great,but how can I add all my driver path to it, so I can select it just like Windows Explorer!
Originally posted by: Sarath Bhooshan S
ITs working perfect in Win2000 Professional. Thanks a lot
ReplyOriginally posted by: kenshee
Is there any way I could get the system to scan if the flopppy or any drives are used using MFC??Thanks..
ReplyOriginally posted by: Sebastien Martin
I built a similar class as the one posted here using only API functions, but I couldn't figure out how to make the icons highlighted. (Not just turning every second pixel to a blue color, but acutally shading every pixel to a shade of blue like Win98/NT4/2K do. The original author mentioned something about masks but I'm still kind of new to image manipulation. Even if you provide an MFC solution, I could probably base my code on it and get it working with win GDI. Thanks.
ReplyOriginally posted by: David Netherwood
Following Tobias Sch�nherr's suggestion I used the SHBrowseForFolder to pick a directory. I works fine, but there is quite a bit of work goes into to getting it work smoothly, so I thought I'd post a fuller example.
#include <windows.h>
#include <shlobj.h>
#include <iostream.h>
// call back function
// we only se it to set the current directory
int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM , char* path)
{
switch (uMsg)
{
case BFFM_INITIALIZED:
// Driretory browser intializing - tell it where to start from
PostMessage (hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)path);
break;
}
return 0;
}
int main(int argc, char** argv)
{
// Browser parameter block
BROWSEINFO bi;
memset (&bi, 0, sizeof(bi));
// Path variable
char path[_MAX_PATH] = "C:\\Temp";
// Initialize COM
CoInitialize(NULL);
// Get root point to browse from
// Can use NULL for all - which in effect is what we are doing here
LPITEMIDLIST pidlRoot = NULL;
SHGetSpecialFolderLocation(HWND_DESKTOP, CSIDL_DESKTOP /*CSIDL_DRIVES*/, &pidlRoot);
// Setup Browse parameter block
bi.pidlRoot = pidlRoot;
bi.ulFlags = BIF_RETURNONLYFSDIRS;
bi.lpfn = (BFFCALLBACK)BrowseCallbackProc;
bi.lParam = (LPARAM)path;
// Call browse
LPITEMIDLIST Selection;
Selection = SHBrowseForFolder(&bi);
// If went OK, decode return to produce the selected path
if (!NULL)
SHGetPathFromIDList(Selection, path);
// Now free up the memory allocated by the various COM
// objects we accessed indirectly
LPMALLOC lpMalloc = NULL;
if (!SHGetMalloc(&lpMalloc) && (NULL != lpMalloc))
{
if (pidlRoot)
lpMalloc->Free(pidlRoot);
if (Selection)
lpMalloc->Free(Selection);
}
// Print path to console
cout << path << endl;
return 0;
}
Originally posted by: TERAHI
No comment....
ReplyOriginally posted by: Xiaolong Wu
this comment concerns the author's improvement plan #2. the plan is to add icons to the edit box. if we have a closer look at the "combobox" on the top of the CFileDiaolog, we can see that it is not a usual CComboBox. the original edit box is replaced by a CButton. one cannot type in it. When one clicks on it, it behaves just like the arrow button on the right.
so for the author's improvement plan #2, we need to combine two buttons and a CListBox.the CListBox will be hiden most of the time until user clicks on the buttons.
I tried to install a button on a combobox to cover the editbox. but didn't work. when the combobox gets focus, the button dispeared. CComboBox does not give us a handle to the edit box. CComboBoxEx does, but the item data stucture is quite different.
xiaolong wu