This content is provided AS IS for archive purposes only. Content may be out of date with no guarantee of correctness.

Progress Bars - Elements - Hag GUI for Cobra - Static

Main Article

Progress Bars - Elements - Hag GUI for Cobra

Progress Bars using the XP theme.

Progress bars are rectangular elements used to convey the progress of a task.

Progress bars expose the following read-only variables:

progressbar.x: Integer - Progress bar x position
progressbar.y: Integer - Progress bar y position
progressbar.w: Integer - Progress bar width
progressbar.h: Integer - Progress bar height
progressbar.enabled: Boolean - If progress bar is enabled
progressbar.visible: Boolean - If progress bar is visible

For a ready-to-run example, see Example_Progressbar in the Examples download.


Program (icon:"hag\icons\window.ico")

   frmMain: ^forms
       prgMain: ^progressBars
       sliMain: ^sliders
       tbxMain: ^textBoxes
       btnClose: ^buttons
   background: Element
   i: Integer
   str: String


   SetAppName("Progress bar example")
   OpenScreen(320, 240, 32, FALSE, COB_SHOWBORDER+COB_SHOWCLOSE)
   background = CreateSprite(320,240)
   Cls(ToRGBA(235,233,237),background) ; Flip

   // Init GUI
   HagInit(320, 240, 1) // Start at sprite index 1 because of the background sprite    
   // Set up GUI Elements
   frmMain = CreateForm()
       tbxMain = CreateTextBox(frmMain, 20, 80, 80, "0")
       sliMain = CreateSlider(frmMain, 120, 85, 180)
           SliderSetPercent(sliMain, 0)
       prgMain = CreateProgressBar(frmMain, 20, 120, 280)
           ProgressBarPercent(prgMain, 0)
       btnClose = CreateButton(frmMain, 250, 207, 50, "Close")
   While ExitRequested = FALSE

       If SliderUpdated(sliMain) then
           ProgressBarPercent(prgMain, SliderGetPercent(sliMain))
           TextBoxSetContents(tbxMain, ToString(SliderGetPercent(sliMain)))
TextBoxUpdated(tbxMain) then
           str = TextBoxContents(tbxMain)
           If Length(str) > 0 then
               SliderSetPercent(sliMain, ToInt(str))
               ProgressBarPercent(prgMain, ToInt(str))
ButtonClicked(btnClose) then RequestExit

       If KeyHits(VK_ESCAPE) > 0 then RequestExit


Stay Subscribed

@golightlyb, subscribe to the RSS feed or get updates by e-mail.

You can also contact me directly - I make an effort to reply to every e-mail.