Company: Armitage Technologies Ltd. Generated by CasualWriter on 2003/02/07 21:09:30

Details of D:\ckhung\cw7\CW.PBL(w_progress)

[Window] w_progress from Window
[Description] * display a progress bar and <cancel> button for long process
Size (*.srw): 3,969 Updated on 13-Jun-1999 19:41

Control List
Type Name  Remarks
Window <w_progress>  Type=popup!; Title="Process in progress, please wait...";
commandbutton cb_cancel  Tab=2; Text="&Cancel";
u_progress_bar dw_pct  
statictext st_msg  Disable; Text="Percentage of progress";

Variables
Type Declaration
Instance Variable // percentage of progress
Instance Variable decimal id_progress
Instance Variable boolean ib_continue = TRUE

Script List
Control Type Name Bytes Line
w_progress Event open 926 31
w_progress PublicFunc wf_progress (decimal ad_progress) return boolean 167 9
w_progress PublicFunc wf_progress (decimal ad_progress, string as_text) return boolean 190 10
w_progress PublicProc wf_setmsg (string as_text) 57 3
w_progress PublicProc wf_settitle (string as_title) 50 3
cb_cancel ControlEvent clicked 147 4

Event w_progress.open
//$ Desription:
//$   This window is used to display a progress bar with <cancel> button> for long
//$   process.
//$
//$ Functions:
//$   wf_settitle()         set the window title
//$   wf_setmsg()            set the display message
//$   wf_progress()         display the current progress
//$
//$ Example:
//$   long i, j, l
//$   open(w_progress)
//$   for i = 1 to 100
//$      for j=1 to 100
//$      next
//$      if not w_progress.wf_progress( i / 100, 'processing '+string(i) ) then exit
//$   next
//$   close(w_progress)
//$
//$ Log:
//$   1997/12/29   C.K. Hung   Initial Version
//$--------------------------------------------------------------------------------------
//$ Copyright (c) 1997, C.K. Hung, All rights reserved. (http://www.intercon.net/~ckhung/)
//$======================================================================================

// set bar style
dw_pct.of_setstyle(1)

// init flag app.ib_cancel
app.ib_cancel = FALSE

PublicFunc wf_progress (decimal ad_progress) return boolean
// display percentage
dw_pct.of_progress(ad_progress)

// handle outstanding message
do while yield()
loop

// return the flag of "continue"
return ib_continue

PublicFunc wf_progress (decimal ad_progress, string as_text) return boolean
// display percentage
st_msg.text = as_text
dw_pct.of_progress(ad_progress)

// handle outstanding message
do while yield()
loop

// return the flag of "continue"
return ib_continue

PublicProc wf_setmsg (string as_text)
// Set the display message
st_msg.text = as_text
return

PublicProc wf_settitle (string as_title)
// set window title
this.title = as_title
return

CotrolEvent cb_cancel.clicked
if messagebox( 'CANCEL?', 'Are you sure to abort this process?', STOPSIGN!, YesNo! ) = 1 then
ib_continue = FALSE
app.ib_cancel = TRUE
end if