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

Samples

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

Scrolling Listbox In Dialog

 Keywords: Scroll Scrolling Log Window Rolling Multiline Multilinebox

Example 1: Scrolling Multilinebox using a predefined list


#DefineSubRoutine MyDialogProc(Status_Handle, Status_Message, controlnum, res1, res2)
   ; DialogProcOptions Constants
   MSG_INIT         = 0                                  ; The one-time initilization
   MSG_BUTTONPUSHED = 2                                  ; Pushbutton or Picturebutton
   MSG_TIMER        = 1                                  ; Timer call
   RET_DO_CANCEL    = 0                                  ; Cancels dialog
   RET_DO_DEFAULT   = -1                                 ; Continue with default processing for control
   RET_DO_NOT_EXIT  = -2                                 ; Do not exit the dialog

   Switch Status_Message
      Case MSG_INIT
         DialogProcOptions( Status_Handle,MSG_TIMER,500 )
         Return( -1 )

      Case MSG_TIMER
         DialogContents = DialogControlGet( Status_Handle, 2, 3 )
         newdata = ItemExtract(counter,logdata,@LF)
         If DialogContents =="" Then DialogContents = newdata
         Else DialogContents = StrCat( DialogContents, @CRLF, newdata )
         DialogControlSet( Status_Handle, 2, 3, DialogContents )
         counter = counter + 1
         If counter>maxlines
           DialogProcOptions( Status_Handle,MSG_TIMER,0 );Disable timer
           Return( RET_DO_DEFAULT )
          EndIf
         Return(RET_DO_NOT_EXIT )

      Case MSG_BUTTONPUSHED
         TimeDelay( .5 )
         Return( RET_DO_CANCEL )

   EndSwitch
   Return( 0 )

#EndSubRoutine

maxlines = 100
counter = 1

logData = ''
For item = 1 To maxlines
   If logdata == "" Then logData = 'line ': item : @LF
   Else logData = logData : 'line ': item : @LF
Next

MyDialogFormat=`WWWDLGED,6.1`

MyDialogCaption=`Logging Data`
MyDialogX=2001
MyDialogY=2001
MyDialogWidth=284
MyDialogHeight=185
MyDialogNumControls=004
MyDialogProcedure=`MyDialogProc`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0

MyDialog001=`079,165,120,012,PUSHBUTTON,DEFAULT,"Press to Stop",1,1,32,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`025,067,238,086,MULTILINEBOX,LogBox,DEFAULT,DEFAULT,4,8,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`025,053,044,010,STATICTEXT,DEFAULT,"Status",DEFAULT,5,DEFAULT,"Arial|5632|40|34","0|0|0",DEFAULT`
MyDialog004=`013,005,260,154,GROUPBOX,DEFAULT,DEFAULT,DEFAULT,6,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("MyDialog")

Exit




Example 2: Scrolling Multilinebox using ADO to data from a CSV file


#DefineSubRoutine MyDialogProc(Status_Handle, Status_Message, controlnum, res1, res2)
   ; DialogProcOptions Constants
   MSG_INIT         = 0                                  ; The one-time initilization
   MSG_BUTTONPUSHED = 2                                  ; Pushbutton or Picturebutton
   MSG_TIMER        = 1                                  ; Timer call
   RET_DO_CANCEL    = 0                                  ; Cancels dialog
   RET_DO_DEFAULT   = -1                                 ; Continue with default processing for control
   RET_DO_NOT_EXIT  = -2                                 ; Do not exit the dialog

   Switch Status_Message
      Case MSG_INIT
         DialogProcOptions( Status_Handle,MSG_TIMER,500 )
         Return( -1 )

      Case MSG_TIMER
         DialogContents = DialogControlGet( Status_Handle, 2, 3 )
         newdata = ItemExtract(counter,logdata,@CR)
         If DialogContents =="" Then DialogContents = newdata
         Else DialogContents = StrCat( DialogContents, @CRLF, newdata )
         DialogControlSet( Status_Handle, 2, 3, DialogContents )
         counter = counter + 1
         If counter>maxlines
           DialogProcOptions( Status_Handle,MSG_TIMER,0 );Disable timer
           Return( RET_DO_DEFAULT )
          EndIf
         Return(RET_DO_NOT_EXIT )

      Case MSG_BUTTONPUSHED
         TimeDelay( .5 )
         Return( RET_DO_CANCEL )

   EndSwitch
   Return( 0 )

#EndSubRoutine


counter = 1

adOpenStatic = 3
adLockOptimistic = 3
adCmdText = 1

objConnection = CreateObject("ADODB.Connection")
objRecordSet = CreateObject("ADODB.Recordset")

strPathtoTextFile = DirScript()
textfile = DirScript():"sample.csv"

objConnection.Open(StrCat('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=', strPathtoTextFile,';Extended Properties="text;HDR=YES;FMT=CSVDelimited"'))  ;''
objRecordset.Open(StrCat("SELECT * FROM ",textfile), objConnection, adOpenStatic, adLockOptimistic, adCmdText)

logdata = objRecordset.GetString()
maxlines = ItemCount( logdata, @CR )-1

objRecordset.Close()
objRecordset = 0
objConnection.Close()
objConnection = 0


MyDialogFormat=`WWWDLGED,6.1`

MyDialogCaption=`Logging Data`
MyDialogX=2001
MyDialogY=2001
MyDialogWidth=300
MyDialogHeight=185
MyDialogNumControls=004
MyDialogProcedure=`MyDialogProc`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0

MyDialog001=`079,165,120,012,PUSHBUTTON,DEFAULT,"Press to Stop",1,1,32,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`015,067,270,086,MULTILINEBOX,LogBox,DEFAULT,DEFAULT,4,8,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`015,053,044,010,STATICTEXT,DEFAULT,"Status",DEFAULT,5,DEFAULT,"Arial|5632|40|34","0|0|0",DEFAULT`
MyDialog004=`013,005,275,154,GROUPBOX,DEFAULT,DEFAULT,DEFAULT,6,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("MyDialog")

Exit



CSV File Data - sample.csv
CustID,LastName,FirstName,Address,City,State,Zip
1000,Flintstone,Fred,1230 Stone Road,BedRock,AZ,85000
1001,Rubble,Barney,4560 Pebble Street,BedRock,AZ,85000
1002,Flintstone,Wilma,1230 Stone Road,BedRock,AZ,85000
1003,Rubble,Betty,4560 Pebble Street,BedRock,AZ,85000
1004,Ball,Lucille,55 Love Lane,TelevisionCity,CA,90201
1005,Arnez,Desi,55 Love Lane,TelevisionCity,CA,90201
1006,Boop,Betty,1930 Boop-Boop-A-Doop Loop,Hollywood,CA,90068
1007,Dean,James,1960 Desire Street,Hollywood,CA,90068
1008,Monroe,Marilyn,1962 Norma Jean Ave.,Hollywood,CA,90068
1009,Marley,Bob,333 Reggae Road,St. Ann's Parish,Jamaica,10101

Article ID:   W16426
File Created: 2012:04:18:14:43:44
Last Updated: 2012:04:18:14:43:44