LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

DirSelectPopup usability

I has been my experience that the "DirSelectPopup" function could be improved from a usability perspective. 
 
Specifically, people tend to browse to the parent directory of the "correct" directory that they should select. They then click once on the "correct" directory, thereby highlighting it in blue (just as they would for a file), and click "Done".  The result is that they selected the parent of the one they meant to.
 
Are there any workarounds to this?
 
--Ian
 
 
 
 
0 Kudos
Message 1 of 12
(5,024 Views)
Hi, Ian.

I agree with you; that window's usability is definitely counterintuitive. The only workaround I can think of is to ask the user to select a file whenever possible (as opposed to a directory). For instance, instead of saying, "Select the directory in which the application can find the important system files," say "Select important system file X." Clearly that's not a comprehensive solution, but it could improve things under certain circumstances.

I've filed a product suggestion to R&D about this, so hopefully it'll be fixed in future versions of CVI. Sorry I can't give you a better workaround!
Sarah K.
Search PME
National Instruments
0 Kudos
Message 2 of 12
(5,002 Views)
I can only second that - how often have I seen my users mess up things seriously by selecting wrong directories this way ?!
meanwhile, I have given up using DirSelectPopup at all, I use a self-made function instead of it, which reads a list of relevant (selectable) directories into a string list and then offers the user a ring-control to select from.
much more comprehensive.

--
Once the game is over, the king and the pawn go back into the same box.
0 Kudos
Message 3 of 12
(4,982 Views)
Dont poke around the CVI pages all that often.  I much prefer LabVIEW but I thought this thread was interesting so I broke out my old assembler code and whipped up a DLL which hooks into the standard Windows browse for folder dialog which is much more intuitive.  Of course this makes the routine Windows specific so take it with a grain of salt Smiley Very Happy
 
Anyhow I exported a single function named BrowseFolder which you can import into your project.
 
Prototype:
CStr BrowseFolder( void );
 
Returns a pointer to a character array which will contain the folder chosen in the dialog or it will have a null character in the first position if the dialog was canceled.
 
Any questions/ issues let me know...
 
 
Message 4 of 12
(4,976 Views)

Thanks, Sarah, for putting it in as a suggestion for future versions.

I agree that the strategy of getting them to go to a file could work, but in my case I need them to specify a directory (often empty) in advance. Smiley Sad

--Ian

 

0 Kudos
Message 5 of 12
(4,958 Views)

Chaos,

Thanks -- this is looking good.  I've been able to see the pop-up your DLL generates, and it looks much more intuitive.  

Three questions for you, and/or some LabWindows specialists:

- Would you be able to have it include a "default directory" argument? (Please!)

- Any advice on dealing with the "CStr" type? (What include file defines it?)  I'm struggling to convert it to a simple C "char *" array.

- Should (how could) I directly use the Windows SDK function "BrowseForFolder"?

Many thanks!

--Ian

0 Kudos
Message 6 of 12
(4,953 Views)
1> I dont think this can easily be done.  Its not my dialog after all Smiley Sad its a premade template dialog and am just calling it from the code.  Of course you can always check the return value for NULL and if it is use the default...
 
2> CStr was the name LabVIEW gave to the return value itself in the DLL configuration utility.  Declare a U32 variable for the function return and when you need to use it cast it to a character array.
 
unsigned integer retval;
retval = BrowseFolder();
printf( "%s\n", (char*)retval );
 
(at least thats the way I remember it... will gladly defer to someone who still uses C)
 
3> You should be able to also call it from CVI directly.  You will need to include some Windows headers (shell32 and ole32) and make a call to SHBrowseForFolder.  Lots of good information on this function from Microsoft and other sites...

Message Edited by Chaos on 12-16-2005 04:29 PM

Message 7 of 12
(4,947 Views)

Thanks again, Chaos. I'm able to get at that result now.

For those who are interested, I've attached a small project that implements your DLL.  (I'm not going to pursue the SDK approach.)

Cheers,

Ian

0 Kudos
Message 8 of 12
(4,904 Views)

I know this is a very old discussion, but would you happen to have a 64-bit version of this DLL? I'm looking to upgrade an old LabWindows-based test tool and the software engineer who wrote it apparently used your 32-bit version.

0 Kudos
Message 9 of 12
(2,001 Views)

Something along these lines:

 

#include <ShlObj.h>

/* Parameters
 *   hwndOwner        owner window for dialog
 *   title            title text to display above the tree view control
 *   initialPath      path to start at
 *   selectedPath     receives the user selected path, must be at least MAX_PATH long
 * Returns
 *   TRUE on success, FALSE on error
 */
 
BOOL BrowseForFolder(HWND hWndOwner, char *title, char *initialPath, char *selectedPath)
{
    BOOL retval = FALSE;
    LPITEMIDLIST lpItem;
    BROWSEINFOA bInfo;
    bInfo.hwndOwner = hWndOwner;
    bInfo.pidlRoot = NULL; 
    bInfo.pszDisplayName = initialPath;
    bInfo.lpszTitle = title;
    bInfo.ulFlags = 0; // maybe use BIF_NEWDIALOGSTYLE;
    bInfo.lpfn = NULL;
    bInfo.lParam = 0;
    bInfo.iImage = -1;

    lpItem = SHBrowseForFolderA(&bInfo);
    if (lpItem != NULL)
    {
        if (SHGetPathFromIDListA(lpItem, selectedPath))
            retval = TRUE;
        CoTaskMemFree(lpItem);
    }
    return retval;
}

 

 

 

 

Rolf Kalbermatter
My Blog
0 Kudos
Message 10 of 12
(1,983 Views)