benny69 KiXforms Advocate


Joined: 30 Oct 2003 Posts: 567 Location: Lincoln, Ne
|
Posted: Wed Nov 23, 2005 4:57 am Post subject: Sample ProgressBar |
|
|
Here is a Sample ProgressBar used in the StatusBar:
Code: | Break On
$System = CreateObject("Kixforms.System")
If Not $System
$nul= MessageBox("KiXforms.Net Not Initiated. This Script Will Now Close.","Error",16)
Quit()
EndIf
$nul = $System.Application.EnableVisualStyles
$MainForm = $System.Form()
$MainForm.StartPosition = 1 ;FormStartPosition_CenterScreen
$MainForm.Size = $System.Size(401,150) ;(Width,Height)
$MainForm.Text = "Sample ProgressBar"
$MainPanel = $System.Panel()
$MainPanel.Dock = 5 ;Fill
$nul = $MainForm.Controls.Add($MainPanel)
$StatusBar = $System.StatusBar()
$nul = $MainForm.Controls.Add($StatusBar)
$ProgressBar = $System.ProgressBar()
$ProgressBar.Left = $StatusBar.Right-20-100
$ProgressBar.Height = 18
$ProgressBar.Top = 3
$ProgressBar.Width = 100
$ProgressBar.Value = 0
$ProgressBar.Visible = 0
$nul = $StatusBar.Controls.Add($ProgressBar)
$GroupBox = $System.GroupBox()
$GroupBox.Height = $MainForm.ClientRectangle.Height-$StatusBar.Height-5
$GroupBox.Left = $MainForm.ClientRectangle.Left+5
$GroupBox.Top = $MainForm.ClientRectangle.Top;+5
$GroupBox.Width = $MainForm.ClientRectangle.Width-10
$nul = $MainPanel.Controls.Add($GroupBox)
$Label = $System.Label()
$Label.Height = 60
$Label.Left = 10
$Label.TextAlign = 32 ;MiddleCenter
$Label.Top = 20
$Label.Width = 370
$nul = $GroupBox.Controls.Add($Label)
$MainForm.AcceptButton = $Start
$MainForm.CancelButton = $Stop
$MainForm.Show ;Displays the Form
StartProcesses()
While $MainForm.Visible
$Nul = Execute($MainForm.DoEvents())
Loop
Exit 0
Function ExitForm()
Quit()
EndFunction
Function AdvanceProgressBar($Step,Optional $Text)
$Count = $Count + $Step
If $Count > 100
$Count = 0
EndIf
$ProgressBar.Value = $Count
$ProgressBar.Refresh
$StatusBar.Text = $Text
Sleep 0.03
EndFunction
Function StartProcesses()
$GroupBox.Text = "Process"
$processes = "Checking Groups...","Modifying Registry...","Mapping Drives...","Creating Icons...","Adding Printers...","Finalizing..."
$ProgressBar.Visible = -1
For Each $process in $processes
$X=$x+1
$Label.Text = $process
AdvanceProgressBar(10,"Process #"+$x)
Sleep 1
Next
ResetProgressBar()
$GroupBox.Text = ""
Sleep 1
ExitForm()
EndFunction
Function ResetProgressBar()
$Count = 0
AdvanceProgressBar(0,"")
$Label.Text = ""
$ProgressBar.Visible = 0
EndFunction
|
_________________ Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta) |
|