The following picture shows a standard window with at the left side the directory control.

With a simple call the directory can be queried.
| Parameter | Description |
| HAB | hab - anchorblock handle, mandatory |
| HWND | hParent - The window handle of the parent. |
| LONG | controlid - This is the contol number used to create the window/control. Must be unique in the program. The control uses the controlid number plus controlid+1. |
| LONG | flAttribute - Can be zero or CV_MINI. Defines the display size of the pictured in the control. |
| ULONG | ulNotify - When needed you can ask to be notified on a directory selection change. Specify a value > WM_USER. The specified message id will be used to notify the parent window. |
Example:
myTree = new dirCtrl(hab,hwnd,TREE_ID,CV_MINI,0)This construction implies that we have to ask for the selected directory since the last parameter is smaller than WM_USER. Further, the icon will be shown in small format due to the CV_MINI defined in the constructor. TREE_ID is just a #define TREE_ID 100, but that's up to you. The control is created standard with a Helvetica 8 points font, which can be changed.
BOOL dirCtrl::getDirectoryName( char *szBuf, int iSize) ;
Example
On a menu selection or on a button click in your app, you want to know what the selected directoy is
case WM_COMMAND:
switch(LOUSHORT(mp1)) {
case IDM_NEW:
myTree->getDirectoryName(szDirectory,
sizeof(szDirectory));
break;
szDirectory will contain the selected directory on return. To be
sure
you can check on the return value of the method. It returns false when
the given buffer is too small. Use a buffer of 255 chars and you are on
the save side.
Getting notified.
The control sends a message when a selection lasts longer than one second. So you will not be notified during selection changes but only when the selection is stable for a while.
Example:
#define UM_LETMEKNOW WM_USER+100
myTreeIn the window procedure the following code will do the job,
= new dirCtrl(hab,hwnd,TREE_ID,CV_MINI,UM_LETMEKNOW);
switch(msg)A buffer of 255 chars length will be sufficient.
{
case
UM_LETMEKNOW:
STRCPY(szBuf,(char *)mp1);
.....