WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Dialog Editor
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Choosing a Directory in a dialog

Keywords: choosing Directory dialog	 

Question:

In an application i'm writing, i'm required to have a UI that asks the user to specify a directory. What is the best way to go about choosing a Directory in a dialog? I've tried the following, but it changes the value to NOFILESELECTED. Any ideas?
        IntControl(4, 0, 0, 0, 0)
        disks=`*.`
        HomeDirDialogFormat=`WWWDLGED,5.0`
        HomeDirDialogCaption=`Choose the directory`
        HomeDirDialogX=284
        HomeDirDialogY=85
        HomeDirDialogWidth=159
        HomeDirDialogHeight=118
        HomeDirDialogNumControls=3
        HomeDirDialog01=`6,16,80,54,FILELISTBOX,disks,DEFAULT`
        HomeDirDialog02=`62,84,64,DEFAULT,PUSHBUTTON,DEFAULT,"&Ok",1`
        HomeDirDialog03=`6,2,148,DEFAULT,VARYTEXT,disks,""`
        ButtonPushed=Dialog("HomeDirDialog")
        message(`You chose`,disks)

Answer:

A side effect of working through the directories is that the current WinBatch directory also changes. You can ignore the "NOFILESSELECTED" by doing the following. It's the same as yours except for the last couple of lines.
	IntControl(4, 0, 0, 0, 0)
	disks=`c:\*.`
	HomeDirDialogFormat=`WWWDLGED,5.0`
	HomeDirDialogCaption=`Choose the directory`
	HomeDirDialogX=284
	HomeDirDialogY=85
	HomeDirDialogWidth=159
	HomeDirDialogHeight=118
	HomeDirDialogNumControls=3
	HomeDirDialog01=`6,16,80,54,FILELISTBOX,disks,DEFAULT`
	HomeDirDialog02=`62,84,64,DEFAULT,PUSHBUTTON,DEFAULT,"&Ok",1`
	HomeDirDialog03=`6,2,148,DEFAULT,VARYTEXT,disks,""`
	ButtonPushed=Dialog("HomeDirDialog")

	disks=DirGet() ;;;;;;;;;;Da magic
	message(`You chose`,disks)

Question:

I've tried the example above, but it's not really what I'm looking for. I want to display directories only. The FileListBox displays both files and directories. How do I do this?

Answer:

The FILELISTBOX is designed to display both files and directories. You can use ITEMBOX if you want to only display directories (using a variable assigned to DirItemize). It'll work, but it's not as smart as FILELISTBOX, in terms of not knowing how to update the EDITBOX, like FILELISTBOX would.

Here are two examples of using the dialog editor.

In the first example, the FILELISTBOX is used in combination with the EDITBOX control which can have the same variable name as the FILELISTBOX. If you do, the user can type a file mask into the EDITBOX which will cause the FILELISTBOX to be redrawn with the display only those files that match the new file mask specification. Also in combination with the FILELISTBOX, you can use the VARYTEXT control, which may also use the same variable as the FILELISTBOX. If you do so, the VARYTEXT will display the current directory as displayed in the FILELISTBOX. For FILELISTBOX, the last parameter must be DEFAULT. The FileListBox doesn't display directories only, even if you use the DirItemize function. It's not designed that way.

In the second example, the ITEMBOX control is used with DirItemize.

Here's the FILELISTBOX Method:

	Dirchange("D:\TEMP\")
	intcontrol(4,0,0,0,0)


	dirs=FileItemize("*.*")

	joedialogFormat=`WWWDLGED,5.0`

	joedialogCaption=`Choose a Directory`
	joedialogX=2
	joedialogY=21
	joedialogWidth=146
	joedialogHeight=206
	joedialogNumControls=6

	joedialog01=`6,26,64,DEFAULT,EDITBOX,dirs,"*."`
	joedialog02=`6,44,134,122,FILELISTBOX,dirs,DEFAULT`
	joedialog03=`6,8,64,DEFAULT,VARYTEXT,dirs,"Choose a Directory"`
	joedialog04=`74,28,64,DEFAULT,CHECKBOX,makeadir,"Create Directory",1`
	joedialog05=`6,186,64,DEFAULT,PUSHBUTTON,DEFAULT,"&Ok",1`
	joedialog06=`76,186,64,DEFAULT,PUSHBUTTON,DEFAULT,"&Cancel",0`


	ButtonPushed=Dialog("joedialog")

	message(`You chose the directory`,dirs)

	if makeadir == 1  
	   if !DirExist(dirs) then DirMake(dirs)
	endif

And here's the ITEMBOX Method:

Note that inlike FILELISTBOX, the ITEMBOX control cannot share the same variables as the EDITBOX and VARYTEXT controls.
	Dirchange("D:\TEMP\")
	intcontrol(4,0,0,0,0)

	dirs=DirItemize("*.*")


	joedialogFormat=`WWWDLGED,5.0`

	joedialogCaption=`Choose a Directory`
	joedialogX=2
	joedialogY=21
	joedialogWidth=146
	joedialogHeight=206
	joedialogNumControls=6

	joedialog01=`6,26,64,DEFAULT,EDITBOX,xdirs,"*."`
	joedialog02=`6,44,134,122,ITEMBOX,dirs,dirs`
	joedialog03=`6,8,64,DEFAULT,VARYTEXT,ydirs,"Choose a Directory"`
	joedialog04=`74,28,64,DEFAULT,CHECKBOX,makeadir,"Create Directory",1`
	joedialog05=`6,186,64,DEFAULT,PUSHBUTTON,DEFAULT,"&Ok",1`
	joedialog06=`76,186,64,DEFAULT,PUSHBUTTON,DEFAULT,"&Cancel",0`



	ButtonPushed=Dialog("joedialog")

	message(`You chose the directory`,dirs)

	if makeadir == 1 
	   if !DirExist(dirs) then DirMake(dirs)
	endif

Article ID:   W12831
Filename:   Choosing a Directory in a Dialog.txt
File Created: 1999:04:15:16:49:56
Last Updated: 1999:04:15:16:49:56