Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


File Browser within Dialog

 Keywords:  

Question:

I am creating a dialog that needs to allow the user to pick a file from their hard drive. I have no clue where on their PC that the file might reside. Something on the order of a 'browse' function similiar to what you can do with file explorer. Is this possible?????

Answer:

#DefineFunction ConfigProc(ConfigDlgHandle,ConfigDlgMessage,ConfigDlgControlID,param4,param5)
   InitDialog=0 
   DC_ButtonPressed= 2 ; some constant we define laters
   DC_SetTitle = 3
   Switch ConfigDlgMessage

          Case InitDialog   ; Init_Dialog  (case number 0 subject to change on implementation)
               DialogProcOptions(ConfigDlgHandle,DC_ButtonPressed,1)   ; enable buttonclicked messages
               Return (-1)
   
          Case DC_ButtonPressed
              Switch ConfigDlgControlID
                  Case 3   ; the browse button
                     x=AskFilename("Choose your file","","All Files|*.*","*.*",1)
                     DialogControlSet(ConfigDlgHandle,4,DC_SetTitle,x)
                     :CANCEL ; Capture cancel from AskFileName
                     Return(-2)  ; don't exit
               EndSwitch   ;ConfigDlgControlID
               Return(-1)  ; do default processing

   EndSwitch ; ConfigDlgMessage
   Return(-1) ; Do default processing#EndFunction
#EndFunction


ConfigDlgFormat=`WWWDLGED,6.1`

ConfigDlgCaption=`Configuration Options`
ConfigDlgX=-01
ConfigDlgY=-01
ConfigDlgWidth=257
ConfigDlgHeight=072
ConfigDlgNumControls=005
ConfigDlgProcedure=`ConfigProc`
ConfigDlgFont=`DEFAULT`
ConfigDlgTextColor=`DEFAULT`
ConfigDlgBackground=`DEFAULT,128|255|128`

ConfigDlg001=`068,044,035,014,PUSHBUTTON,DEFAULT,"OK",1,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
ConfigDlg002=`119,044,035,014,PUSHBUTTON,DEFAULT,"Cancel",0,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
ConfigDlg003=`209,020,035,014,PUSHBUTTON,DEFAULT,"Browse",2,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
ConfigDlg004=`007,020,192,014,EDITBOX,DaFile,"",DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
ConfigDlg005=`009,006,187,009,STATICTEXT,DEFAULT,"Filename:",DEFAULT,DEFAULT,DEFAULT,"Microsoft Sans Serif|5325|70|34","0|0|0",DEFAULT`

ButtonPushed=Dialog("ConfigDlg")

Message("Selected File",DaFile)
Exit