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

Forms - Elements - Hag GUI for Cobra - Static

Main Article

Forms - Elements - Hag GUI for Cobra

Forms are invisible elements that you parent other elements to. This makes it easy to move, enable, show, hide, free, etc, several elements at the same time.

It is important to only have one form enabled (use EnableForm) at a time if these forms contain text-boxes or buttons, as using tab to cycle through text-boxes or pressing enter to activate a focused button will apply to all forms at the same time.

Forms expose the following read-only variables:

form.x: Integer - Form x position
form.y: Integer - Form y position
form.enabled: Boolean - If form is enabled
form.visible: Boolean - If form is visible

Example: (For a more in-depth example of forms, see Example2D in the Examples download)

Program
   Uses

       cobra2D,
       keyset,
       hagC2D
 
Var   
   form1 : ^forms
       button1a : ^buttons
   
   background: Element

Begin
 
   OpenScreen(800,600,32,FALSE,COB_SHOWBORDER)
   
   background = CreateSprite(800,600)
   CLS(ToRGBA(200,200,200), background)
   
   HagBaseDir("hag\")
   HagInit(800,600, 1)    
   HagLoadGuiTheme("xp")

   form1 = CreateForm("frm1")
       button1a = CreateButton(form1, 10, 10, 100, "Hello")

   HagUpdateOnce()

 
   While Not KeyDown(VK_ESCAPE)

       HagUpdateAll_AutoKeys()
   
       Flip
       Pause
(1)
   Wend

   HagFreeAll()
 
   CloseScreen
End

  

Stay Subscribed

Follow me on twitter @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.


Login
v0.34.archive