November 25, 2020, 05:33:46 AM

Author Topic: [bb] VisualB for quickgui by churchaxe [ 1+ years ago ]  (Read 600 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] VisualB for quickgui by churchaxe [ 1+ years ago ]
« on: June 29, 2017, 12:28:38 AM »
Title : VisualB for quickgui
Author : churchaxe
Posted : 1+ years ago

Description : For people who like the quickgui system by wickedrush, here is a graphical editor/form designer. You can place/resize buttons and everything, set properties etc, save/reload
the forms/windows and export all the stuff into BlitzBasic code.

Edit:
I've been reported that about 1 or 2 functions are missing...
if so, please add the following code to either quickgui.bb or the main-.bb-file:

Function gui_getMode(name)
   For a.gui_gadget=Each gui_gadget
      If a
um=name Then Return amode
   Next
End Function

Function gui_setMode(name,md)
   For a.gui_gadget=Each gui_gadget
    If a
um=name Then amode=md
   Next
End Function

I've made a few fixes in the quickgui.bb for my own personal use, but I left them out for this version, which uses the original and unmodified files of quickgui (version 1.08)
delivered by wickedrush. One little warning: beware of pressing the del-key in an activated and empty input-gadget. This causes an error in gui_handleinput
(at least on my computer...)

As far as it is my own code it's free for use and whatever you wanna do with it - at your own risk :)

You also need these 2 files:
  quickgui.bb (which is the actual gui system)
  quickGui_fileRequestor.bb   (file open/save dialogs, this is also part of the quickgui package)
<a href="codearcs9950.html?code=229" target="_blank">http://www.blitzbasic.com/codearcs/codearcs.php?code=229[/url]

Note that this app needs at least 1024x768 display size, otherwise it won't show the bottom parts of the control window. For those people who have 1024x768, it's best
to run it with Graphics 1024, 768, 32, 1 (fullscreen). If your display is 1280x1024 run it at 1024x768/windowed. 800x600 is very bad whether windowed or fullscreen.
If you get lost in too big windows, remember: F1=help and ESC=quit... :P

Note also that it uses the SystemProperty("APPDIR") as a starting point, which means that if you run it from the IDE it will put its settings-file "VisualB.ini" in your Blitz...in folder.
If you run it as an .exe it'll use the directory the visualb.exe actually is in.


Code :
[code=blitzbasic]Graphics 1024, 768, 32, 2
SetBuffer BackBuffer()

Include "quickgui.bb"   ;put in correct path
Include "quickgui_filerequestor.bb"

FreeFont gui_font
gui_font = LoadFont("Arial", 12, True)
SetFont gui_font
gui_usepointer = True

ClsColor 128, 128, 128

Global act   ;selected gadget in form=window under construction
Global ctrlpos
Global cyclic_ids
Global dir_app$ = SystemProperty("APPDIR")
Global dir_img$ = dir_app
Global dir_open$ = dir_app
Global dir_snd$ = dir_app
Global endprog
Global exp_fulapp
Global exp_gadselect
Global exp_modal
Global fatmark
Global form
Global formih
Global formimg$
Global frmfile$
Global gadsel
Global mx, my
Global newwidth, newheight
Global posx, posy
Global wait

Type gad
   Field id
   Field noclick
   Field rightclick
   Field inputgadget
   Field container_for
   Field slider_in
   Field vertical
   Field ni$, nih
   Field di$, dih
   Field oi$, oih
   Field os$, osh
   Field ds$, dsh
End Type

If LoadINI() Then msgbox("if you need some HELP please press F1", 0, "First start...")
AppTitle frmfile + " - VisualB"

While Not endprog
   mx = MouseX()
   my = MouseY()
   Cls
   
   ShowPointer

   gadsel = gui_update(0, wait)
   g.gad = GetGad(gadsel)

   If g <> Null      ;gadget in form selected
      act = gadsel
      FillCtrl()
   ElseIf gadsel > 0   ;gadget in CtrlWin selected
      Flip
   EndIf
   
   If act <> 0 And KeyDown(56)      ;test slider movement
      g = GetGad(act)
      If (gslider_in <> 0)
         tmp$ = gui_handleSlider(act, form, act, gslider_in, gvertical, True)
         Color 255, 255, 0
         Text 230, 30, "slider value = " + tmp
         FillCtrl
      EndIf
   EndIf

   Color 0, 0, 0
   Text 230, 0, "mouse: x = " + mx + "   y = " + my

   ;red marker for selected item
   If Not gui_gethandle(1000)
      Color 255, 0, 0
      If act > 0
         rx = gui_getx(act) + gui_getwinx(form)
         rw = gui_getw(act)
      Else
         rx = gui_getwinx(form)
         rw = gui_getwinw(form)
      EndIf
      
      If gui_gethandle(1)
         If ctrlpos = 0
            If rx < 227
            rw = rw - 227 + rx
            rx = 227
            EndIf
         ElseIf rx + rw > ctrlpos
            rw = ctrlpos - rx
         EndIf
      EndIf

      If act > 0
         Rect rx, gui_gety(act) + gui_getwiny(form), rw, gui_geth(act), False
         If fatmark Then Rect rx + 1, gui_gety(act) + gui_getwiny(form) + 1, rw - 2, gui_geth(act) - 2, False
      Else
         Rect rx, gui_getwiny(form), rw, gui_getwinh(form), False
         If fatmark Then Rect rx + 1, gui_getwiny(form) + 1, rw - 2, gui_getwinh(form) - 2, False
      EndIf
      Color 0, 0, 0
   EndIf

   enteringtext = False
   For a.gui_gadget = Each gui_gadget
      If amode And 2048
         enteringtext =  True
         Exit
      EndIf
   Next
   If Not enteringtext Then GetuserInput()

   Flip
Wend
SaveINI()
End      

Function ApplyAll()
   If act <> 0
      g.gad = GetGad(act)
      
      align = GetAlign(3)
      gui_settext(act, gui_gettext(2), align)

      ;types
      tmp1$ = gui_gettext(16)
      tmp2$ = gui_gettext(17)
      tmp3$ = gui_gettext(18)
      
      gui_settypes(act, Int(tmp1), Int(tmp2), Int(tmp3))

      x = gui_gettext(23)
      y = gui_gettext(24)
      width = gui_gettext(25)
      height = gui_gettext(26)

      Select Int(tmp1)   ;fixed height for radiobtns and checkboxes
         Case 13, 14
            gui_setsize(act, width, 13)
            gui_settext(26, "13")
         Case 15, 16
            gui_setsize(act, width, 12)
            gui_settext(26, "12")
         Default
            gui_setsize(act, width, height)
      End Select

      gui_setposition(act, x, y)      

      SetGadID()   

      ;set slider/container
      tmp1 = gui_gettext(34)
      If tmp1 <> ""
         g2.gad = GetGad(Int(tmp1))
         If g2 <> Null
            If g2id <> act
               If g2slider_in <> 0
                  MsgBox("Gadget " + g2id + " is already a slider in " + g2slider_in, 0, "Setting container...")
                  If Not(gui_getmode(34) And 2048)
                     gui_setmode(34, gui_getmode(34) + 2048)
                     gui_textcursorpos = 0
                     gui_settext(34, "")
                  EndIf
               ElseIf g2container_for <> 0 And (g2container_for <> gid)
                  MsgBox("Gadget " + g2id + " is already a container for " + g2container_for, 0, "Setting container...")
                  If Not(gui_getmode(34) And 2048)
                     gui_setmode(34, gui_getmode(34) + 2048)
                     gui_textcursorpos = 0
                     gui_settext(34, "")
                  EndIf
               Else
                  g3.gad = GetGad(gslider_in)
                  If g3 <> Null
                     g3container_for = 0
                     g3
oclick = False
                  EndIf
                  gslider_in = g2id
                  If gvertical
                     gui_settext(33, "vertical")
                  Else
                     gui_settext(33, "horizontal")
                  EndIf
                  g2
oclick = True
                  g2container_for = act
               EndIf
            Else
               If gslider_in <> 0
                  gui_settext(34, gslider_in)
               Else
                  gui_settypes(32, 15)
                  gui_settext(34, "")
               EndIf
            EndIf
         Else
            MsgBox("There's no gadget number " + tmp1 + " in Form " + form + ".", 0, "Setting container...")
            If gslider_in <> 0
               gui_settext(34, gslider_in)
            Else
               gui_settypes(32, 15)
               gui_settext(34, "")
            EndIf
         EndIf
      EndIf
   Else   ;form
      align = GetAlign(form)
      SetWinText(form, gui_gettext(2), align)

      ;type
      tmp1$ = gui_gettext(16)
      For a.gui_gadget = Each gui_gadget
         If a
um = 0 And awindownum = form Then a   yp = Int(tmp1)
      Next
   
      x = gui_gettext(23)
      y = gui_gettext(24)
      width = gui_gettext(25)
      height = gui_gettext(26)
      
      gui_setwinxy(form, x, y)
      gui_setwinsize(form, width, height)
   EndIf
   
   ;find/goto gadget
   tmp1 = gui_gettext(55)
   If tmp1 <> ""
      If Int(tmp1) = form
         gui_settext(55, "")
         act = 0
         FillCtrl()
         Return
      EndIf

      For g.gad = Each gad
         If gid = Int(tmp1)
            act = gid
            gui_settext(55, "")
            FillCtrl()
            Return
         EndIf
      Next
      If g = Last gad Or g = Null
         MsgBox("There's no gadget number " + tmp1 + " in Form " + form + ".", 0, "Goto Gadget...")
         gui_settext(55, "")
      EndIf
   EndIf
   
   ;change filename
   tmp1$ = gui_gettext(57)
   If tmp1 <> "unnamed"
      If Lower(Right(tmp1, 4)) <> ".vbf"
         If Instr(tmp1, ".") Then tmp1 = Left(tmp1, Instr(tmp1, ".") - 1)
         tmp1 = tmp1 + ".vbf"
      Else
         tmp1 = tmp1
      EndIf
      
      If frmfile <> tmp1
         frmfile = tmp1
         saveform(frmfile)
         AppTitle frmfile + " - VisualB"
      EndIf
      gui_settext(57, tmp1, 1)
   EndIf
   
   ;change to new FormID
   tmp1$ = gui_gettext(49)
   If Int(tmp1) <> form
      SetFormID(Int(tmp1))
   EndIf
   
   gui_redrawwindow(form)
   gui_redrawwindow(1)
End Function

Function CtrlWin()
   If gui_gethandle(1) Then gui_freewindow(1)

   gui_makewindow(1, 226, 768, 0, 1)
   gui_makegadget(1, 1, 1, 27, 29, 15, 5, 8, "text", 1)
   gui_makegadget(1, 2, 27, 27, 195, 15, 261, 2, "texttext", 1)
   gui_makegadget(1, 3, 99, 6, 122, 15, 1, 1, "alignment", 1)
   gui_makegadget(1, 4, 4, 70, 42, 15, 5, 8, "modes", 1)
   gui_makegadget(1, 5, 5, 90, 55, 12, 5, 15, "noclick", 2)
   gui_makegadget(1, 6, 5, 105, 67, 12, 5, 15, "nosunken", 2)
   gui_makegadget(1, 7, 5, 120, 66, 12, 5, 15, "rightclick", 2)
   gui_makegadget(1, 8, 5, 135, 57, 12, 5, 15, "shadow", 2)
   gui_makegadget(1, 9, 5, 150, 46, 12, 5, 15, "ghost", 2)
   gui_makegadget(1, 10, 5, 165, 81, 12, 5, 15, "autobrighten", 2)
   gui_makegadget(1, 11, 5, 180, 45, 12, 5, 15, "input", 2)
   gui_makegadget(1, 12, 160, 71, 42, 15, 5, 8, "types", 2)
   gui_makegadget(1, 13, 132, 91, 42, 15, 5, 8, "normal", 2)
   gui_makegadget(1, 14, 132, 114, 42, 15, 5, 8, "over", 2)
   gui_makegadget(1, 15, 132, 137, 42, 15, 5, 8, "down", 2)
   gui_makegadget(1, 16, 176, 91, 25, 15, 261, 2, "16", 0)
   gui_makegadget(1, 17, 176, 114, 25, 15, 261, 2, "15", 0)
   gui_makegadget(1, 18, 176, 137, 25, 15, 261, 2, "11", 0)
   gui_makegadget(1, 19, 5, 210, 40, 14, 5, 8, "X", 2)
   gui_makegadget(1, 20, 5, 229, 40, 14, 5, 8, "Y", 2)
   gui_makegadget(1, 21, 5, 248, 40, 14, 5, 8, "width", 2)
   gui_makegadget(1, 22, 5, 267, 40, 14, 5, 8, "height", 2)
   gui_makegadget(1, 23, 50, 210, 35, 15, 261, 2, "xval", 0)
   gui_makegadget(1, 24, 50, 229, 35, 15, 261, 2, "yval", 0)
   gui_makegadget(1, 25, 50, 248, 35, 15, 261, 2, "wval", 0)
   gui_makegadget(1, 26, 50, 267, 35, 15, 261, 2, "hval", 0)
   gui_makegadget(1, 27, 110, 190, 110, 15, 1, 1, "compress IDs now", 0)
   gui_makegadget(1, 28, 142, 248, 64, 15, 1, 1, "duplicate", 0)
   gui_makegadget(1, 29, 142, 267, 64, 15, 1, 1, "delete", 0)
   gui_makegadget(1, 30, 1, 6, 42, 15, 5, 8, "gadget", 1)
   gui_makegadget(1, 31, 41, 6, 46, 15, 261, 2, "gadID", 0)
   gui_makegadget(1, 32, 1, 306, 108, 12, 5, 15, "slider in container", 2)
   gui_makegadget(1, 33, 163, 306, 56, 15, 1, 1, "vertical", 0)
   gui_makegadget(1, 34, 110, 306, 46, 15, 261, 2, "containerID", 0)
   gui_makegadget(1, 35, 6, 359, 45, 15, 5, 8, "images", 1)
   gui_makegadget(1, 36, 6, 379, 25, 15, 5, 8, "ni", 1)
   gui_makegadget(1, 37, 6, 399, 25, 15, 5, 8, "oi", 1)
   gui_makegadget(1, 38, 6, 419, 25, 15, 5, 8, "di", 1)
   gui_makegadget(1, 39, 6, 445, 46, 15, 5, 8, "sounds", 1)
   gui_makegadget(1, 40, 6, 465, 25, 15, 5, 8, "os", 1)
   gui_makegadget(1, 41, 6, 485, 25, 15, 5, 8, "ds", 1)
   gui_makegadget(1, 42, 21, 379, 200, 15, 1, 1, "nival", 0)
   gui_makegadget(1, 43, 21, 399, 200, 15, 1, 1, "oival", 0)
   gui_makegadget(1, 44, 21, 419, 200, 15, 1, 1, "dival", 0)
   gui_makegadget(1, 45, 21, 465, 200, 15, 1, 1, "osval", 0)
   gui_makegadget(1, 46, 21, 485, 200, 15, 1, 1, "dsval", 0)
   gui_makegadget(1, 47, 142, 229, 64, 15, 1, 1, "insert", 0)
   gui_makegadget(1, 48, 3, 520, 32, 12, 5, 8, "form", 0)
   gui_makegadget(1, 49, 38, 518, 50, 15, 261, 2, "formID", 0)
   gui_makegadget(1, 50, 100, 518, 50, 15, 1, 1, "new", 0)
   gui_makegadget(1, 51, 160, 518, 50, 15, 1, 1, "open", 0)
   gui_makegadget(1, 52, 100, 538, 50, 15, 1, 1, "save", 0)
   gui_makegadget(1, 53, 160, 598, 50, 15, 1, 1, "export", 0)
   gui_makegadget(1, 54, 1, 52, 79, 12, 5, 8, "goto", 0)
   gui_makegadget(1, 55, 80, 50, 46, 15, 261, 2, "", 0)
   gui_makegadget(1, 56, 4, 562, 52, 12, 5, 8, "filename", 1)
   gui_makegadget(1, 57, 53, 561, 166, 15, 261, 2, "filenameval", 1)
   gui_makegadget(1, 58, 156, 746, 64, 15, 1, 1, "quit", 0)
   gui_makegadget(1, 59, 5, 598, 103, 12, 5, 15, "long gadgetIDs", 2)
   gui_makegadget(1, 60, 5, 623, 201, 13, 5, 13, "full application", 2)
   gui_makegadget(1, 61, 36, 638, 136, 13, 5, 13, "without selector", 2)
   gui_makegadget(1, 62, 36, 654, 137, 13, 5, 13, "select / case selector", 2)
   gui_makegadget(1, 63, 36, 670, 137, 13, 5, 13, "if / then / else selector", 2)
   gui_makegadget(1, 64, 5, 719, 202, 13, 5, 13, "form and gadget code only", 2)
   gui_makegadget(1, 65, 119, 686, 53, 12, 5, 15, "modal", 2)
   gui_makegadget(1, 66, 1, 326, 108, 15, 5, 8, "container for slider", 0)
   gui_makegadget(1, 67, 110, 326, 46, 15, 5, 8, "sliderID", 0)
   gui_makegadget(1, 68, 110, 170, 110, 12, 5, 15, "cyclic IDs", 2)
   gui_makegadget(1, 69, 38, 538, 50, 15, 1, 1, "reload", 0)
   gui_makegadget(1, 70, 142, 50, 64, 15, 1, 1, "IDs info", 0)
   gui_makegadget(1, 71, 7, 746, 64, 15, 1, 1, "help", 0)
   gui_makegadget(1, 72, 160, 538, 50, 15, 1, 1, "save as", 0)

   gui_settiptext(2, "F2")
   gui_settiptext(28, "Ctrl/Shift+D")
   gui_settiptext(29, "Ctrl+X")
   gui_settiptext(33, "horizontal/vertical")
   gui_settiptext(47, "Ins")
   gui_settiptext(50, "Ctrl+N")
   gui_settiptext(51, "Ctrl+O")
   gui_settiptext(52, "Ctrl+S")
   gui_settiptext(53, "Ctrl+E")
   gui_settiptext(55, "F3")
   gui_settiptext(58, "Alt+F4")
   gui_settiptext(69, "Ctrl+Z")
   gui_settiptext(70, "Ctrl+I")
   gui_settiptext(71, "F1")

   gui_drawwindow(1, ctrlpos, 0)

   If exp_fulapp = True
      gui_settypes(60, 14)
      gui_settypes(64, 13)
      If exp_modal
         gui_settypes(65, 16)
      Else
         gui_settypes(65, 15)
      EndIf
      If exp_gadselect = 0
         gui_settypes(61, 14)
         gui_settypes(62, 13)
         gui_settypes(63, 13)
      ElseIf exp_gadselect = 1
         gui_settypes(61, 13)
         gui_settypes(62, 14)
         gui_settypes(63, 13)
      Else
         gui_settypes(61, 13)
         gui_settypes(62, 13)
         gui_settypes(63, 14)
      EndIf
   Else
      gui_settypes(60, 13)
      gui_settypes(64, 14)
      gui_settypes(65, 15)
      gui_settypes(61, 13)
      gui_settypes(62, 13)
      gui_settypes(63, 13)
   EndIf
   
   If cyclic_ids Then gui_settypes(68, 16)
   
   FillCtrl()
   gui_drawwindow(1, ctrlpos, 0)
End Function

Function Export()
   If Instr(frmfile, ".")
      expfile$ = dir_open + Left(frmfile, Instr(frmfile, ".") - 1) + ".bb"
   Else
      expfile$ = dir_open + frmfile + ".bb"
   EndIf

   fileh = WriteFile(expfile)

      WriteLine(fileh, ";created by VisualB")
      
      If exp_fulapp   ;sample app code
         WriteLine(fileh, "Graphics 1024, 768, 32, 2")
         WriteLine(fileh, "SetBuffer BackBuffer()")
         WriteLine(fileh, "Include " + Chr(34) + "quickGui.bb" + Chr(34) + "   ;complete with correct path")
         WriteLine(fileh, "")
         WriteLine(fileh, "FreeFont gui_font")
         WriteLine(fileh, "gui_font = LoadFont(" + Chr(34) + "Arial" + Chr(34) + ", 12, True)")
         WriteLine(fileh, "SetFont gui_font")
         WriteLine(fileh, "gui_usepointer = True")
         WriteLine(fileh, "Global debugtext$")

         If exp_gadselect > 0
            WriteLine(fileh, "Global gui_wait")
            WriteLine(fileh, "Global gadsel")
            WriteLine(fileh, "")
         EndIf

         If Not exp_modal Then WriteLine(fileh, "CreateWindow()")

         WriteLine(fileh, "")
         WriteLine(fileh, "While Not KeyHit(1)      ;mainloop")
         WriteLine(fileh, "   Cls")
         If exp_gadselect > 0
            WriteLine(fileh, "   gadsel = gui_update(0, gui_wait)")
         Else
            WriteLine(fileh, "   gadsel = gui_update()")
         EndIf
         
         If exp_modal = False
            For g.gad = Each gad
               If gslider_in <> 0
                  If actline = False
                     WriteLine(fileh, "   If gadsel Then act = gadsel")
                     actline = True
                  EndIf

                  If gui_gettype(59) = 16
                     exp_ID$ = Str(form) + Str(gid - form)
                     exp_ID2$ = Str(form) + Str(gslider_in - form)
                  Else
                     exp_ID = gid
                     exp_ID2 = gslider_in
                  EndIf
         
                  WriteLine(fileh, "   If act = " + exp_ID + " Then debugtext = gui_HandleSlider(act, " + form + ", " + exp_ID + ", " + exp_ID2 + ", " + gvertical + ", True)")
               EndIf
            Next

            WriteLine(fileh, "")
            If exp_gadselect > 0 Then WriteLine(fileh, "   HandleGuiInput()")
            WriteLine(fileh, "   If debugtext <> " + Chr(34) + Chr(34))
            WriteLine(fileh, "      Color 255, 0, 0")
            WriteLine(fileh, "      Text 0, 0, debugtext")
            WriteLine(fileh, "   EndIf")
            WriteLine(fileh, "")
         ElseIf exp_modal
            WriteLine(fileh, "   Color 255, 255, 255")
            WriteLine(fileh, "   If retval Then t$ = " + Chr(34) + " again" + Chr(34))
            WriteLine(fileh, "   Text 0, 0, " + Chr(34) + "hit SPACE to start window function" + Chr(34) + " + t + " + Chr(34) + ", ESC To Exit program" + Chr(34))
            WriteLine(fileh, "   If KeyHit(57)")
            WriteLine(fileh, "      FlushKeys")
            WriteLine(fileh, "      retval = CreateWindow()")
            WriteLine(fileh, "   EndIf")
            WriteLine(fileh, "")
            WriteLine(fileh, "   If retval")
            WriteLine(fileh, "      Color 255, 255, 0")
            WriteLine(fileh, "      Text 0, 30, " + Chr(34) + "returned value = " + Chr(34) + " + retval")
            WriteLine(fileh, "   EndIf")
            WriteLine(fileh, "")
         EndIf

         WriteLine(fileh, "   Flip")
         WriteLine(fileh, "Wend")
         WriteLine(fileh, "End")
         WriteLine(fileh, "")

         If exp_gadselect
            WriteLine(fileh, "Function HandleGUIInput()")

            If exp_gadselect = 1
               WriteLine(fileh, ";gadget selector type: select/case")
               WriteLine(fileh, "   Select gadsel")
               For g.gad = Each gad
                  If Not g
oclick
                     If gui_gettype(59) = 16
                        exp_ID$ = Str(form) + Str(gid - form)
                        WriteLine(fileh, "   Case " + exp_ID)
                        WriteLine(fileh, "      debugtext = " + Chr(34) + "gadget " + Chr(34) + " + " + exp_ID + " + " + Chr(34) + " selected" + Chr(34))
                     Else
                        WriteLine(fileh, "   Case " + gid)
                        WriteLine(fileh, "      debugtext = " + Chr(34) + "gadget " + Chr(34) + " + " + gid + " + " + Chr(34) + " selected" + Chr(34))
                     EndIf
                  EndIf
               Next
               WriteLine(fileh, "   End Select")
               WriteLine(fileh, "")
            ElseIf exp_gadselect = 2
               WriteLine(fileh, ";gadget selector type: if/then/else")
               For g.gad = Each gad
                  If gui_gettype(59) = 16
                     exp_ID$ = Str(form) + Str(gid - form)
                     If g = First gad
                        WriteLine(fileh, "   If gadsel = " + exp_ID)
                        WriteLine(fileh, "      debugtext = " + Chr(34) + "gadget " + Chr(34) + " + " + exp_ID + " + " + Chr(34) + " selected" + Chr(34))
                     ElseIf Not g
oclick
                        WriteLine(fileh, "   ElseIf gadsel = " + exp_ID)
                        WriteLine(fileh, "      debugtext = " + Chr(34) + "gadget " + Chr(34) + " + " + exp_ID + " + " + Chr(34) + " selected" + Chr(34))
                     EndIf
                  Else
                     If g = First gad
                        WriteLine(fileh, "   If gadsel = " + gid)
                        WriteLine(fileh, "      debugtext = " + Chr(34) + "gadget " + Chr(34) + " + " + gid + " + " + Chr(34) + " selected" + Chr(34))
                     ElseIf Not g
oclick
                        WriteLine(fileh, "   ElseIf gadsel = " + gid)
                        WriteLine(fileh, "      debugtext = " + Chr(34) + "gadget " + Chr(34) + " + " + gid + " + " + Chr(34) + " selected" + Chr(34))
                     EndIf
                  EndIf
               Next
               WriteLine(fileh, "   EndIf")
            EndIf

            WriteLine(fileh, "   If MouseDown(1)")
            WriteLine(fileh, "      gui_wait = True")
            WriteLine(fileh, "   Else")
            WriteLine(fileh, "      gui_wait = False")
            WriteLine(fileh, "   EndIf")
            WriteLine(fileh, "End Function")
            WriteLine(fileh, "")
         EndIf

         WriteLine(fileh, "Function CreateWindow()")

         If exp_modal      ;modal test win
            WriteLine(fileh, ";program stops until dialog is terminated")
            WriteLine(fileh, ";returns 1 when ended with ESC, 2 when ended with ENTER")
            WriteLine(fileh, "")
         EndIf
      EndIf

      w_x = gui_getwinx(form)
      w_y = gui_getwiny(form)
      w_width = gui_getwinw(form)
      w_height = gui_getwinh(form)
      w_type = GetWinType(form)
      WriteLine(fileh, "   gui_makewindow(" + form + ", " + w_width + ", " + w_height + ", 0, " + w_type + ")")

      For g.gad = Each gad   ;gadgets
         If gui_gettype(59) = 16
            exp_ID = Str(form) + Str(gid - form)
         Else
            exp_ID = gid
         EndIf
         
         width = gui_getw(gid)
         height = gui_geth(gid)
         mode =  gui_getmode(gid)
         If g
oclick Then mode = mode + 2
         If gightclick Then mode = mode + 8
         If gInputgadget Then mode = mode + 256

         nt =  gui_gettype(gid)
         ot = GetOverType(gid)
         dt = GetDownType(gid)

         ni$ = g
i
         oi$ = goi
         di$ = gdi
         os$ =  gos
         ds$ =  gds

         WriteLine(fileh, "   gui_makegadget(" + form + ", " + exp_ID + ", " + gui_getx(gid) + ", " + gui_gety(gid) + ", " + width + ", " + height + ", " + mode + ", " + nt + ", " + Chr(34) + gui_gettext(gid) + Chr(34) + ", " + GetAlign(gid) + ")")
         If (ot Or dt) Then WriteLine(fileh, "      gui_settypes(" + exp_ID + ", " + nt + ", " + ot + ", " + dt + ")")
         If g
i <> ""
            WriteLine(fileh, "      nih = LoadImage(" + Chr(34) + g
i + Chr(34) + ")")
            WriteLine(fileh, "      If nih <> 0 Then nih = gui_givebutton(nih, " + width + ", " + height + ")")
            tmp1$ = "nih"
         Else
            tmp1$ = Chr(34) + Chr(34)
         EndIf
         If goi <> ""
            WriteLine(fileh, "      oih = LoadImage(" + Chr(34) + goi + Chr(34) +  ")")
            WriteLine(fileh, "      If oih <> 0 Then oih = gui_givebutton(oih, " + width + ", " + height + ")")
            tmp2$ = "oih"
         Else
            tmp2$ = Chr(34) + Chr(34)
         EndIf
         If gdi <> ""
            WriteLine(fileh, "      dih = LoadImage(" + Chr(34) + gdi + Chr(34) +  ")")
            WriteLine(fileh, "      If dih <> 0 Then dih = gui_givebutton(dih, " + width + ", " + height + ")")
            tmp3$ = "dih"
         Else
            tmp3$ = Chr(34) + Chr(34)
         EndIf
         If g
i <> "" Or goi <> "" Or gdi <> ""
            WriteLine(fileh, "      gui_setimages(" + exp_ID + ", 0, 0, " + tmp1 + ", " + tmp2 + ", " + tmp3 + ")")
            WriteLine(fileh, "")
         EndIf

         If gos <> ""
            WriteLine(fileh, "      osh = LoadSound(" + Chr(34) + gos + Chr(34) + ")")
            tmp1$ = "osh"
         Else
            tmp1$ = Chr(34) + Chr(34)
         EndIf
         If gds <> ""
            WriteLine(fileh, "      dsh = LoadSound(" + Chr(34) + gds + Chr(34) +  ")")
            tmp2$ = "dsh"
         Else
            tmp2$ = Chr(34) + Chr(34)
         EndIf
         If gos <> "" Or gds <> ""
            WriteLine(fileh, "      gui_setsounds(" + exp_ID + ", " + tmp1 + ", " + tmp2 + ")")
            WriteLine(fileh, "")
         EndIf
      Next

      WriteLine(fileh, "")
      WriteLine(fileh, "   gui_drawwindow(" + form + ", " + w_x + ", " + w_y + ")")
      If exp_modal And exp_fulapp
         WriteLine(fileh, "")
         WriteLine(fileh, "   Repeat      ;loop")
         WriteLine(fileh, "      Cls")
         WriteLine(fileh, "      Color 255, 255, 255")
         WriteLine(fileh, "      Text 0, 0, " + Chr(34) + "hit ESC to exit and return 1" + Chr(34))
         WriteLine(fileh, "      Text 0, 10, " + Chr(34) + "hit ENTER to exit and return 2" + Chr(34))
         WriteLine(fileh, "      gadsel = gui_update(" +  form + ", gui_wait)")

            For g.gad = Each gad
               If gslider_in <> 0
                  If actline = False
                     WriteLine(fileh, "      If gadsel Then act = gadsel")
                     WriteLine(fileh, "")
                     actline = True
                  EndIf

                  If gui_gettype(59) = 16
                     exp_ID$ = Str(form) + Str(gid - form)
                     exp_ID2$ = Str(form) + Str(gslider_in - form)
                  Else
                     exp_ID = gid
                     exp_ID2 = gslider_in
                  EndIf
         
                  WriteLine(fileh, "      If act = " + exp_ID + " Then debugtext = gui_HandleSlider(act, " + form + ", " + exp_ID + ", " + exp_ID2 + ", " + gvertical + ", True)")
               EndIf
            Next
            
         If exp_gadselect > 0
            WriteLine(fileh, "")
            WriteLine(fileh, "      HandleGuiInput()")
         EndIf

         WriteLine(fileh, "")
         WriteLine(fileh, "      If debugtext <> " + Chr(34) + Chr(34))
         WriteLine(fileh, "         Color 255, 0, 0")
         WriteLine(fileh, "         Text 0, 30, debugtext")
         WriteLine(fileh, "      EndIf")
         WriteLine(fileh, "")

         WriteLine(fileh, "      Flip")
         WriteLine(fileh, "")
         WriteLine(fileh, "      If KeyHit(1)")
         WriteLine(fileh, "         FlushKeys")
         WriteLine(fileh, "         gui_freewindow(" + form + ")")
         If exp_gadselect Then WriteLine(fileh, "         debugtext = " + Chr(34) + Chr(34))
         WriteLine(fileh, "         Return 1")
         WriteLine(fileh, "      ElseIf KeyHit(28)")
         WriteLine(fileh, "         FlushKeys")
         WriteLine(fileh, "         gui_freewindow(" + form + ")")
         If exp_gadselect Then WriteLine(fileh, "         debugtext = " + Chr(34) + Chr(34))
         WriteLine(fileh, "         Return 2")
         WriteLine(fileh, "      EndIf")
         WriteLine(fileh, "   Forever")
      EndIf
      If exp_fulapp Then WriteLine(fileh, "End Function")

   CloseFile(fileh)
End Function

Function FillCtrl()
   gui_settext(57, frmfile, 1)
   gui_settext(49, form)
   If act > 0
      g.gad = GetGad(act)
      
      If gcontainer_for <> 0
         gui_settext(67, gcontainer_for)
      Else
         gui_settext(67, "")
      EndIf

      If gslider_in <> 0
         gui_settypes(32, 16)
         gui_settext(34, gslider_in)
         If gvertical
            gui_settext(33, "vertical")
         Else
            gui_settext(33, "horizontal")
         EndIf
      Else
         gui_settypes(32, 15)
         gui_settext(33, "")
         gui_settext(34, "")
      EndIf

      gui_settext(2, gui_gettext(act), 1)
      
      ;modes
      mode = gui_getmode(act)
      If g
oclick Then
         gui_settypes(5, 16)
      Else
         gui_Settypes(5, 15)
      EndIf

      If mode And 4 Then
         gui_settypes(6, 16)
      Else
         gui_settypes(6, 15)
      EndIf

      If gightclick Then
         gui_settypes(7, 16)
      Else
         gui_settypes(7, 15)
      EndIf

      If ginputgadget Then
         gui_settypes(11, 16)
      Else
         gui_settypes(11, 15)
      EndIf

      If mode And 16 Then
         gui_settypes(8, 16)
      Else
         gui_settypes(8, 15)
      EndIf

      If mode And 32 Then
         gui_settypes(9, 16)
      Else
         gui_settypes(9, 15)
      EndIf
      If mode And 64 Then
         gui_settypes(10, 16)
      Else
         gui_settypes(10, 15)
      EndIf
      
      gui_settext(31, act)
      ntyp = gui_gettype(act)
      gui_settext(16, ntyp)
      gui_settext(17, GetOverType(act))
      gui_settext(18, GetDownType(act))

      align = GetAlign(act)
      If ntyp > 12 And ntyp < 17
         tmp1$ = "right"
         align = 2
      Else
         If align = 0
            tmp1$ = "center"
         ElseIf align = 1
            tmp1 = "left"
         ElseIf align = 2
            tmp1 = "right"
         EndIf
      EndIf
      
      gui_settext(3, tmp1 + " align", align)
      gui_settypes(3, 1)

      If g
i <> ""
         gui_settext(42, g
i)
      Else
         gui_settext(42, "(none)")
      EndIf
      If goi <> ""
         gui_settext(43, goi)
      Else
         gui_settext(43, "(none)")
      EndIf
      If gdi <> ""
         gui_settext(44, gdi)
      Else
         gui_settext(44, "(none)")
      EndIf
      If gos <> ""
         gui_settext(45, gos)
      Else
         gui_settext(45, "(none)")
      EndIf
      If gds <> ""
         gui_settext(46, gds)
      Else
         gui_settext(46, "(none)")
      EndIf
      gui_settext(23, gui_getx(act))
      gui_settext(24, gui_gety(act))
      gui_settext(25, gui_getw(act))
      gui_settext(26, gui_geth(act))
   Else   ;form
      gui_settypes(32, 15)
      gui_settext(33, "")
      gui_settext(34, "")
      gui_settext(67, "")

      tmp1$ = GetWinText(form)

      If tmp1 = ""
         gui_settext(2, tmp1)
      Else
         gui_settext(2, tmp1, 1)
      EndIf

      align = GetAlign(form)
      If align = 0
         tmp1$ = "center"
      ElseIf align = 1
         tmp1 = "left"
      ElseIf align = 2
         tmp1 = "right"
      EndIf
      
      gui_settext(3, tmp1 + " align", align)
      gui_settypes(3, 1)

      gui_settypes(5, 15)
      gui_settypes(6, 15)
      gui_settypes(7, 15)
      gui_settypes(8, 15)
      gui_settypes(9, 15)
      gui_settypes(10, 15)
      gui_settypes(11, 15)

      mode = gui_getmode(0)
      If mode And 2
         gui_settypes(5, 16)
      ElseIf mode And 4
         gui_settypes(6, 16)
      ElseIf mode And 8
         gui_settypes(7, 16)
      ElseIf mode And 16
         gui_settypes(8, 16)
      ElseIf mode And 32
         gui_settypes(9, 16)
      ElseIf mode And 64
         gui_settypes(10, 16)
      ElseIf mode And 256
         gui_settypes(11, 16)
      EndIf

      ntyp = GetWinType(form)
      gui_settext(16, ntyp)
   
      gui_settext(31, "")
      gui_settext(43, "")
      gui_settext(44, "")
      gui_settext(45, "")
      gui_settext(46, "")
      If formimg <> ""
         gui_settext(42, formimg)
      Else
         gui_settext(42, "(none)")
      EndIf
      gui_settext(23, gui_getwinx(form))
      gui_settext(24, gui_getwiny(form))
      gui_settext(25, gui_getwinw(form))
      gui_settext(26, gui_getwinh(form))
      gui_settext(17, "")
      gui_settext(18, "")
   EndIf
   If gui_gethandle(1) Then gui_redrawwindow(1)
End Function

Function GetAlign(name)
   For w.gui_gadget = Each gui_gadget
      If w
um = name Or (wwindownum = name And w
um = 0)
         Return wjustify
      EndIf
   Next
End Function

Function GetDownType(name)
   For w.gui_gadget = Each gui_gadget
      If w
um = name
         Return wdown_gad_type
      EndIf
   Next
End Function

Function GetFreeID(num)
   If num < form + 1 Then num = form + 1
   g.gad = First gad
   If g = Null Then Return num
   
   Repeat
      For g = Each gad
         If num = gid Then Exit   ;not free
         If g = Last gad
            Return num
         EndIf
      Next
      num = num + 1
   Forever
End Function

Function GetGad.gad(id)
   For g.gad = Each gad
      If gid = id Then Return g
   Next
End Function

Function GetOverType(name)
   For w.gui_gadget = Each gui_gadget
      If w
um = name
         Return wover_gad_type
      EndIf
   Next
End Function

Function GetUserInput()
   If (MouseHit(3) Or MouseHit(2))      ;init pos for pan/scale
      If act > 0
         posx = mx - gui_getwinx(form) - gui_getx(act)
         posy = my - gui_getwiny(form) - gui_gety(act)
      Else
         posx = mx - gui_getwinx(form)
         posy = my - gui_getwiny(form)
      EndIf
      MouseXSpeed()
      MouseYSpeed()
   EndIf

   If MouseDown(2)      ;pan
      If act > 0
         If KeyDown(42) Or KeyDown(54)      ;horiz
            newx = mx - gui_getwinx(form) - posx
            newy = gui_gety(act)
         ElseIf KeyDown(29) Or KeyDown(157)   ;vert
            newx = gui_getx(act)
            newy = my - gui_getwiny(form) - posy
         Else                        ;both
            newx = mx - gui_getwinx(form) - posx
            newy = my - gui_getwiny(form) - posy
         EndIf

         gui_setposition(act, newx, newy)
      Else   ;form
         If KeyDown(42) Or KeyDown(54)
            newx = mx - posx
            newy = gui_getwiny(form)
         ElseIf KeyDown(29) Or KeyDown(157)
            newx = gui_getwinx(form)
            newy = my - posy
         Else
            newx = mx - posx
            newy = my - posy
         EndIf
         gui_setwinxy(form, newx, newy)
      EndIf
      gui_redrawwindow(form)
      FillCtrl()
   ElseIf MouseDown(3)   ;scale
      mxspd# = MouseXSpeed()
      myspd# = MouseYSpeed()
      If act > 0
         If KeyDown(42) Or KeyDown(54)      ;width
            newwidth = gui_getw(act) + mxspd
            newheight = gui_geth(act)
         ElseIf KeyDown(29) Or KeyDown(157)   ;height
            newwidth = gui_getw(act)
            newheight = gui_geth(act) + myspd
         Else                        ;both
            newwidth = gui_getw(act) + mxspd
            newheight = gui_geth(act) + myspd
         EndIf
         If newwidth < 25 Then newwidth = 25
         If newheight < 10 Then newheight = 10
         nt = gui_gettype(act)

         Select nt   ;radiobtns/checkboxes (needs fix in quickgui.bb)
            Case 13, 14
               newheight = 13
            Case 15, 16
               newheight = 12
         End Select
         gui_setsize(act, newwidth, newheight)

      Else   ;form
         If KeyDown(42) Or KeyDown(54)
            newwidth = gui_getwinw(form) + mxspd
            newheight = gui_getwinh(form)
         ElseIf KeyDown(29) Or KeyDown(157)
            newwidth = gui_getwinw(form)
            newheight = gui_getwinh(form) + myspd
         Else
            newwidth = gui_getwinw(form) + mxspd
            newheight = gui_getwinh(form) + myspd
         EndIf
         If newwidth < 100 Then newwidth = 100
         If newheight < 50 Then newheight = 50
         gui_setwinsize(form, newwidth, newheight)
      EndIf
      gui_redrawwindow(form)
      FillCtrl()
   EndIf
   
   If MouseDown(3) = False And newwidth <> 0 And newheight <> 0
      If act > 0
         UpdImages(GetGad(act))
         gui_redrawwindow(form)
      Else
         UpdImages(Null)
         gui_redrawwindow(form)
      EndIf
      newwidth = 0
      newheight = 0
   EndIf
   
   If MouseDown(1) Or MouseDown(2) Or MouseDown(3)
      wait = True
   Else
      wait = False
   EndIf
   
   If KeyHit(28)   ;return
      ApplyAll()
   ElseIf gadsel = 58
      waitformouse()
      endprog = True
   ElseIf KeyHit(62)   ;f4
      If gui_gethandle(1)
         gui_freewindow(1)
      Else
         CtrlWin()
      EndIf
   ElseIf KeyHit(45) And (KeyDown(29) Or KeyDown(157)) Or gadsel = 29   ;ctrl+X
      waitformouse()
      If act = 0 Then Return
      g.gad = GetGad(act)
      FreeImage g
ih
      FreeImage goih
      FreeImage gdih
      FreeSound gosh
      FreeSound gdsh
      
      If gcontainer_for
         g2.gad = GetGad(gcontainer_for)
         g2slider_in = 0
      EndIf
      
      If gslider_in
         g2.gad = GetGad(gslider_in)
         g2container_for = 0
      EndIf

      Delete g
      
      For w.gui_gadget = Each gui_gadget
         If w
um = act
            Delete w.gui_gadget
            Exit
         EndIf
      Next
      If cyclic_IDs Then SortIDs()
      act = 0
      gui_redrawwindow(form)
      FillCtrl()
   ElseIf KeyHit(31) And (KeyDown(29) Or KeyDown(157)) Or gadsel = 52 Or gadsel = 72   ;save
      waitformouse()
      tmp$ = gui_gettext(57)
      
      If Lower(Left(tmp, 9) = "unnamed") Or gadsel = 72
         gui_filter(0) = ".vbf"
         tmp = gui_Filerequestor("Save file as...", dir_open, "", GraphicsWidth()/2 - 225, GraphicsHeight()/2 - 160)
   
         If tmp <> ""
            For position = Len(tmp) - 1 To 1 Step - 1
               If Mid(tmp, position, 1) = ""
                  path$ = Left(tmp, position)
                  Exit
               EndIf
            Next
   
            If Lower(Right(tmp, 4)) <> ".vbf" Then tmp = tmp + ".vbf"
      
            dir_open = path         
            SaveForm(Right(tmp, Len(tmp) - Len(path)))
         EndIf
      ElseIf tmp <> ""
         If Lower(Right(tmp, 4)) <> ".vbf" Then tmp = tmp + ".vbf"
         SaveForm(tmp)
      EndIf
   ElseIf KeyHit(24) And (KeyDown(29) Or KeyDown(157)) Or gadsel = 51   ;open
      waitformouse()
      FlushKeys
      gui_filter(0) = ".vbf"
      tmp$ = gui_filerequestor("Open file...", dir_open, "", GraphicsWidth()/2 - 225, GraphicsHeight()/2 - 160)

      If tmp <> ""
         For position = Len(tmp) - 1 To 1 Step - 1
            If Mid(tmp, position, 1) = ""
               path$ = Left(tmp, position)
               Exit
            EndIf
         Next

         dir_open = path
         LoadForm(Right(tmp, Len(tmp) - Len(path)))
      EndIf
   ElseIf KeyHit(32) And (KeyDown(29) Or KeyDown(42)) Or gadsel = 28   ;dup gad, shift=horiz, ctrl=vert
      If act = 0 Then Return
      oldgad.gad = GetGad(act)

      width = gui_getw(act)
      height = gui_geth(act)

      If KeyDown(42)
         x = gui_getx(act) + width + 5
         y = gui_gety(act)
      Else
         x = gui_getx(act)
         y = gui_gety(act) + height + 5
      EndIf

      mode = gui_getmode(act)
      nt = gui_gettype(act)
      ot = GetOverType(act)
      dt = GetDownType(act)
      align = GetAlign(act)
      
      g.gad = New gad
      gid = GetFreeID(form + 1)
      g
oclick = oldgad
oclick
      gightclick = oldgadightclick
      ginputgadget = oldgadinputgadget
      g
i = oldgad
i
      goi = oldgadoi
      gdi = oldgaddi
      gos = oldgados
      gds = oldgadds
      
      gui_makegadget(form, gid, x, y, width, height, mode, 1, gid, align)
      gui_settypes(gid, nt, ot, dt)
      
      act = gid
      UpdImages(g)
      UpdSounds(g)
      gui_redrawwindow(form)
      FillCtrl()
      waitformouse()
   ElseIf KeyHit(49) And (KeyDown(29) Or KeyDown(157)) Or gadsel = 50   ;new form
      waitformouse()
      For g.gad = Each gad
         FreeImage g
ih
         FreeImage goih
         FreeImage gdih
         FreeSound gosh
         FreeSound gdsh
         Delete g
      Next
      frmfile = "unnamed"
      
      gui_freewindow(form)
      form = 100
      gui_makewindow(form, 400, 300, 0, 1)
      gui_drawwindow(form, 260, 60)
      
      act = 0

      AppTitle frmfile + " - VisualB"
      CtrlWin()
      FillCtrl()
   ElseIf KeyHit(210) Or gadsel = 47   ;ins-new gad
      g.gad = New gad
      gid = GetFreeID(form + 1)
      
      gui_makegadget(form, gid, 50, 50, 60, 25, 1, 1, gid)
      act = gid
      FillCtrl()
      gui_redrawwindow(form)
      waitformouse()
   ElseIf gadsel = 27   ;compress IDs
      waitformouse()
      retval = MsgBox("Gadget IDs will be changed. Continue?", 1, "Sort and compress gadget IDs...")
      If retval = 1
         SortIDs()
      EndIf
   ElseIf gadsel = 0 And MouseHit(1) And mx>gui_getwinx(form) And mx<gui_getwinx(form)+gui_getwinw(form) And my>gui_getwiny(form) And my<gui_getwiny(form)+gui_getwinh(form) And KeyDown(56) = False
      ;Lclick: activate form
      act = 0
      FillCtrl()
   ElseIf KeyHit(60)   ;F2 edit text
      FlushKeys
      If Not(gui_getmode(2) And 2048)
         gui_settext(2, "", GetAlign(2))
         gui_setmode(2, gui_getmode(2) + 2048)
         gui_textcursorpos = 0
      EndIf
   ElseIf KeyHit(59) Or gadsel = 71   ;F1 help
      waitformouse()
      txt$ = "Ins - adds new gadget at (form-) position x=50, y=50" + Chr(31) + "LMB - selects item. MMB - resizes, RMB - moves selected item." + Chr(31) + "Shift - limits resizing/moving to horizontal only, "
      txt = txt + "Ctrl - limits to vertical" + Chr(31) + "Enter - applies changes made in control window"  + Chr(31) + Chr(31) + "Some hotkeys can be retrieved by holding the mouse over a button for about "
      txt = txt + "two secs..." + Chr(31) + Chr(31) + "F1 - displays this help" + Chr(31) + "F2 - edit gadget text" + Chr(31) + "F3 - find/goto gadget" + Chr(31) + "F4 - show/hide control window"
      txt = txt + Chr(31) + "F5 - left/right position of control window" + Chr(31) + "F6 - slim/fat gadget marker" + Chr(31) + "Alt+F4 - ends program" + Chr(31) + "Tab/Shift+Tab - jumps from item To item"
      txt = txt + Chr(31) + "Alt+drag - tests slider movement" + Chr(31) + Chr(31) + "SPECIAL THANKS TO THE PEOPLE OF WICKEDRUSH SOFTWARE FOR THE WORK AND POWER THEY PUT IN QUICKGUI!"
      MsgBox(txt, 0, "Help...")
   ElseIf KeyHit(1)
      endprog = True
   ElseIf KeyHit(61)   ;F3   goto
      FlushKeys
      If Not(gui_getmode(55) And 2048)
         gui_setmode(55, gui_getmode(55) + 2048)
         gui_textcursorpos = 0
      EndIf
   ElseIf KeyHit(63)   ;F5 left/right position
      If gui_gethandle(1)
         If  ctrlpos = 0
            ctrlpos = GraphicsWidth() - 227
         Else
            ctrlpos = 0
         EndIf
         CtrlWin()
      EndIf
   ElseIf KeyHit(64)
      fatmark = Not fatmark
   ElseIf KeyHit(23) And (KeyDown(29) Or KeyDown(157)) Or gadsel = 70      ;ctrl+i gad info
      waitformouse()
      For g.gad = Each gad
         gadcount = gadcount + 1
      Next

      tmp1$ = gadcount + " gadgets" + Chr(31) + "Used IDs: "
      For g.gad = Each gad
         If tmp1 = ""
            tmp1 = gid
         Else
            tmp1$ = tmp1 + " " + gid
         EndIf
      Next

      For g.gad = Each gad
         If gid > max Then max = gid
      Next

      tmp1 = tmp1 + Chr(31) + Chr(31) + "Free:"
      For i = form + 1 To max
         free = GetFreeID(i)
         If free = i
            tmp1 = tmp1 + " " + i
         EndIf
      Next
      If Right(tmp1, 1) = ":" Then tmp1 = tmp1 + " (none)"
      MsgBox(tmp1, 0, "Info...")

   ElseIf KeyHit(15)   ;Tab
      If act <> 0
         g.gad = GetGad(act)
         If KeyDown(42)   ;Lshift previous gad
            If g = First gad
               g = Last gad
            Else
               g = Before g
            EndIf
         Else         ;next gad
            If g = Last gad
               g = First gad
            Else
               g = After g
            EndIf
         EndIf
         act = gid
      Else
         If KeyDown(42)
            g = Last gad
         Else
            g = First gad
         EndIf
         If g <> Null
            act = gid
         Else
            act = 0
         EndIf
      EndIf
      FillCtrl()
   ElseIf gadsel = 42 Or gadsel = 43 Or gadsel = 44   ;load image
      tmp1 = gadsel
      waitformouse()
      If act <> 0 Or tmp1 = 42
         gui_filter(0) = ".bmp"
         gui_filter(1) = ".jpg"
         tmp2$ = gui_filerequestor("Load image...", dir_img, "", GraphicsWidth()/2 - 225, GraphicsHeight()/2 - 160)
         FlushMouse()
      Else
         Return
      EndIf

      If act <> 0
         g.gad = GetGad(act)
   
         If tmp1 = 42      ;normalimg
            g
i = tmp2
         ElseIf tmp1 = 43   ;overimg
            goi = tmp2
         ElseIf tmp1 = 44   ;downimg
            gdi = tmp2
         EndIf
         UpdImages(g)
      ElseIf tmp1 = 42
         formimg = tmp2
         UpdImages(Null)
      EndIf

      ;checkout path...
      If tmp2 <> ""
         For position = Len(tmp2) - 1 To 1 Step - 1
            If Mid(tmp2, position, 1) = ""
               path$ = Left(tmp2, position)
               Exit
            EndIf
         Next
         dir_img = path
      EndIf

      gui_redrawwindow(form)
      FillCtrl()
   ElseIf act <> 0 And (gadsel = 45 Or gadsel = 46)   ;load sound
      waitformouse()
      tmp1 = gadsel
      gui_filter(0) = ".wav"
      tmp2$ = gui_filerequestor("Load sound...", dir_snd, "", GraphicsWidth()/2 - 225, GraphicsHeight()/2 - 160)
      FlushMouse()
      g.gad = GetGad(act)

      If tmp1 = 45      ;oversnd
         gos = tmp2
      ElseIf tmp1 = 46   ;downsnd
         gds = tmp2
      EndIf

      If tmp2 <> ""
         For position = Len(tmp2) - 1 To 1 Step - 1
            If Mid(tmp2, position, 1) = ""
               path$ = Left(tmp2, position)
               Exit
            EndIf
         Next
         dir_snd = path
      EndIf

      UpdSounds(g)
      FillCtrl()
   ElseIf gadsel = 3   ;align left/center/right (right needs fix in quickgui)
      If act > 0
         align = GetAlign(act)
         align = align + 1
         If align > 2 Then align = 0
         gui_settext(act, gui_gettext(act), align)
      Else
         align = GetAlign(form)
         align = align + 1
         If align > 2 Then align = 0
         SetWinText(form, gui_gettext(2), align)
      EndIf
      gui_redrawwindow(form)
      FillCtrl()
      waitformouse()

                           ;gad-modes (left out 128)
   ElseIf gadsel = 5 And act > 0   ;2
      g.gad = GetGad(act)
      If gui_gettype(5) = 15
         gui_settypes(5, 16)
         g
oclick = True
      Else
         gui_settypes(5, 15)
         g
oclick = False
      EndIf
      ApplyAll()
      waitformouse()
   ElseIf gadsel = 6 And act > 0   ;4
      mode = gui_getmode(act)
      If gui_gettype(6) = 15
         gui_settypes(6, 16)
         If Not(mode And 4) Then mode = mode + 4
      Else
         gui_settypes(6, 15)
         If mode And 4 Then mode = mode - 4
      EndIf
      gui_setmode(act, mode)
      ApplyAll()
      waitformouse()
   ElseIf gadsel = 7 And act > 0   ;8
      g.gad = GetGad(act)
      If gui_gettype(7) = 15
         gui_settypes(7, 16)
         gightclick = True
      Else
         gui_settypes(7, 15)
         gightclick = False
      EndIf
      ApplyAll()
      waitformouse()
   ElseIf gadsel = 8 And act > 0   ;16
      mode = gui_getmode(act)
      If gui_gettype(8) = 15
         gui_settypes(8, 16)
         If Not(mode And 16) Then mode = mode + 16
      Else
         gui_settypes(8, 15)
         If mode And 16 Then mode = mode - 16
      EndIf
      gui_setmode(act, mode)
      ApplyAll()
      waitformouse()
   ElseIf gadsel = 9 And act > 0   ;32
      mode = gui_getmode(act)
      If gui_gettype(9) = 15
         gui_settypes(9, 16)
         If Not(mode And 32) Then mode = mode + 32
      Else
         gui_settypes(9, 15)
         If mode And 32 Then mode = mode - 32
      EndIf
      gui_setmode(act, mode)
      ApplyAll()
      waitformouse()
   ElseIf gadsel = 10 And act > 0   ;64
      mode = gui_getmode(act)
      If gui_gettype(10) = 15
         gui_settypes(10, 16)
         If Not(mode And 64) Then mode = mode + 64
      Else
         gui_settypes(10, 15)
         If mode And 64 Then mode = mode - 64
      EndIf
      gui_setmode(act, mode)
      ApplyAll()
      waitformouse()
   ElseIf gadsel = 11 And act > 0   ;256
      g.gad = GetGad(act)
      If gui_gettype(11) = 15
         gui_settypes(11, 16)
         ginputgadget = True
      Else
         gui_settypes(11, 15)
         ginputgadget = False
      EndIf
      ApplyAll()
      waitformouse()
   ElseIf KeyHit(18) And (KeyDown(29) Or KeyDown(157)) Or gadsel = 53   ;ctrl-e
      waitformouse()
      export()
   ElseIf gadsel = 60   ;sample app code
      waitformouse()
      gui_settypes(60, 14)
      gui_settypes(64, 13)
      If exp_modal
         gui_settypes(65, 16)
      Else
         gui_settypes(65, 15)
      EndIf
      If exp_gadselect = 0
         gui_settypes(61, 14)
      ElseIf exp_gadselect = 1
         gui_settypes(62, 14)
      Else
         gui_settypes(63, 14)
      EndIf
      exp_fulapp = True
      gui_redrawwindow(1)
   ElseIf gadsel = 64   ;no app code
      waitformouse()
      gui_settypes(64, 14)
      gui_settypes(60, 13)
      gui_settypes(61, 13)
      gui_settypes(62, 13)
      gui_settypes(63, 13)
      gui_settypes(65, 15)
      exp_fulapp = False
      gui_redrawwindow(1)
   ElseIf gadsel = 61   ;no selector
      waitformouse()
      gui_settypes(60, 14)
      gui_settypes(64, 13)
      gui_settypes(61, 14)
      gui_settypes(62, 13)
      gui_settypes(63, 13)
      If exp_modal
         gui_settypes(65, 16)
      Else
         gui_settypes(65, 15)
      EndIf
      exp_gadselect = 0
      exp_fulapp = True
      gui_redrawwindow(1)
   ElseIf gadsel = 62   ;select/case
      waitformouse()
      gui_settypes(60, 14)
      gui_settypes(64, 13)
      gui_settypes(61, 13)
      gui_settypes(62, 14)
      gui_settypes(63, 13)
      If exp_modal
         gui_settypes(65, 16)
      Else
         gui_settypes(65, 15)
      EndIf
      exp_gadselect = 1
      exp_fulapp = True
      gui_redrawwindow(1)
   ElseIf gadsel = 63   ;if/then/else
      waitformouse()
      gui_settypes(60, 14)
      gui_settypes(64, 13)
      gui_settypes(61, 13)
      gui_settypes(62, 13)
      gui_settypes(63, 14)
      If exp_modal
         gui_settypes(65, 16)
      Else
         gui_settypes(65, 15)
      EndIf
      exp_gadselect = 2
      exp_fulapp = True
      gui_redrawwindow(1)
   ElseIf gadsel = 65   ;modal
      waitformouse()
      If gui_gettype(65) = 15
         gui_settypes(65, 16)
         gui_settypes(60, 14)
         gui_settypes(64, 13)

         If exp_gadselect = 0
            gui_settypes(61, 14)
         ElseIf exp_gadselect = 1
            gui_settypes(62, 14)
         Else
            gui_settypes(63, 14)
         EndIf

         exp_fulapp = True
         exp_modal = True
      Else
         gui_settypes(65, 15)
         exp_modal = False
      EndIf
      gui_redrawwindow(1)
   ElseIf gadsel = 59   ;long IDs, export only
      waitformouse()
      If gui_gettype(59) = 15
         gui_settypes(59, 16)
      Else
         gui_settypes(59, 15)
      EndIf
      gui_redrawwindow(1)
   ElseIf gadsel = 32   ;slidergad
      FlushKeys
      If act
         g.gad = GetGad(act)
         waitformouse()
         
         If gcontainer_for <> 0
            g2.gad = GetGad(gcontainer_for)
            MsgBox("Gadget " + act + " is already a container for " + g2id, 0, "Make slider gadget...")
            Return
         EndIf

         If gui_gettype(32) = 15
            gui_settypes(32, 16)
            If Not(gui_getmode(34) And 2048)
               gui_setmode(34, gui_getmode(34) + 2048)   ;container-ID
               gui_textcursorpos = 0
               gui_settext(34, "")
            EndIf
         Else
            If gslider_in <> 0
               g2.gad = GetGad(gslider_in)
               g2container_for = 0
            EndIf
            gslider_in = 0
            gvertical = False
            gui_settext(34, "")
            gui_settypes(32, 15)
            gui_settext(33, "")
         EndIf

         gui_redrawwindow(1)
      EndIf

   ElseIf gadsel = 33   ;vert/horiz slider
      If act
         g.gad = GetGad(act)
         
         waitformouse()
         If gslider_in
            If gui_gettext(33) = "vertical"
               gui_settext(33, "horizontal")
               gvertical = False
            Else
               gui_settext(33, "vertical")
               gvertical = True
            EndIf
         Else
            gui_settext(33, "")
         EndIf
         gui_redrawwindow(1)
      EndIf
   ElseIf gadsel = 68                  
      waitformouse()

      If cyclic_ids   ;starting at form + 1, no gaps in between, e.g. 2001-2002-2003
         cyclic_ids = False
         gui_settypes(68, 15)
      Else         ;noncyclic=IDs only have to be unique, e.g. 2002-2007-2011
         retval = MsgBox("Activating cyclic ID-handling will line up gadget IDs with no gaps in between. " + Chr(31) + "Continue?", 1, "Make IDs cyclic...")
         If retval = 1
            cyclic_ids = True
            gui_settypes(68, 16)
            SortIDs()
         EndIf
      EndIf
      gui_redrawwindow(1)
   ElseIf KeyHit(21) And (KeyDown(29) Or KeyDown(157)) Or gadsel = 69   ;ctrl-z reload
      waitformouse()
      LoadForm(frmfile)
   EndIf
End Function

Function GetWinText$(name)
   For w.gui_gadget = Each gui_gadget
      If wwindownum = name And w
um = 0
         Return w   extstr$
      EndIf
   Next
End Function

Function GetWinType(name)
   For w.gui_gadget = Each gui_gadget
      If w
um = 0 And wwindownum = name
         Return w   yp
      EndIf
   Next
End Function

Function LoadForm(fn$)
   If fn <> "tempfile" Then frmfile = fn

   If FileType(dir_open + fn) = 0
      CtrlWin()
      Return
   EndIf

   For g.gad = Each gad
      FreeImage g
ih
      FreeImage goih
      FreeImage gdih
      FreeSound gosh
      FreeSound gdsh
      Delete g
   Next
   gui_freewindow(form)
   act = 0

   file = ReadFile(dir_open + fn)
   While Not Eof(file)
      zeile$ = ReadLine(file)
      separatorposition = Instr(zeile, "=")
      wert$ = Mid(zeile, separatorposition + 1, -1)

      Select Trim(Mid(zeile, 1, separatorposition - 1))
         Case "cyclic_ids"
            cyclic_ids = wert
         Case "ctrlpos"
            ctrlpos = wert
         Case "form"
            form = wert
            If form < 100 Then form = 100
         Case "w_x"
            w_x = wert
         Case "w_y"
            w_y = wert
         Case "w_width"
            w_width = wert
         Case "w_height"
            w_height = wert
         Case "w_type"
            w_type = wert
            gui_makewindow(form, w_width, w_height, 0, w_type)
         Case "w_img"
            formimg = wert
            If formimg <> "" Then UpdImages(Null)
         Case "w_text"
            txt$ = wert
         Case "w_align"
            align = wert
            SetWinText(form, txt, align)
         Case "gadget"
            id = wert
         Case "noclick"
            noclick = wert
         Case "rightclick"
            rightclick = wert
         Case "inputgadget"
            inputgadget = wert
         Case "slider_in"
            slider_in = wert
         Case "vertical"
            vertical = wert
         Case "x"
            x = wert
         Case "y"
            y = wert
         Case "width"
            width = wert
         Case "height"
            height = wert
         Case "mode"
            mode = wert
         Case "nt"
            nt = wert
         Case "ot"
            ot = wert
         Case "dt"
            dt = wert
         Case "text"
            txt$ = wert
         Case "align"
            align = wert
         Case "ni"
            ni$ = wert
            If ni <> "" And Instr(ni, "") = 0 Then ni = dir_app + ni
         Case "oi"
            oi$ = wert
            If oi <> "" And Instr(oi, "") = 0 Then oi = dir_app + oi
         Case "di"
            di$ = wert
            If di <> "" And Instr(di, "") = 0 Then di = dir_app + di
         Case "os"
            os$ = wert
            If os <> "" And Instr(os, "") = 0 Then os = dir_app + os
         Case "ds"
            ds$ = wert
            If ds <> "" And Instr(ds, "") = 0 Then ds = dir_app + ds

            gui_makegadget(form, id, x, y, width, height, mode, nt, txt, align)
            gui_settypes(id, nt, ot, dt)
            g.gad = New gad
            g
oclick = noclick
            gightclick = rightclick
            ginputgadget = inputgadget
            gslider_in = slider_in
            gvertical = vertical
            gid = id
            g
i = ni
            goi = oi
            gdi = di
            gos = os
            gds = ds
            If g
i <> "" Or goi <> "" Or gdi <> "" Then UpdImages(g)
            If gos <> "" Or gds <> "" Then UpdSounds(g)
      End Select
   Wend
   gui_drawwindow(form, w_x, w_y)
   CloseFile(file)

   For g.gad = Each gad
      If gslider_in
         tmpgad.gad = GetGad(gslider_in)
         tmpgad
oclick = True
         tmpgadcontainer_for = gid
      EndIf
   Next

   CtrlWin()
   AppTitle frmfile + " - VisualB"
End Function

Function LoadINI()
   If FileType(dir_app + "visualb.ini") = 0
      firststart = True
      file = WriteFile(dir_app + "visualb.ini")   ;new ini
         WriteLine(file, "dir_app=" + dir_app)
         WriteLine(file, "dir_open=" + dir_app)
         WriteLine(file, "dir_img=" + dir_img)
         WriteLine(file, "dir_snd=" + dir_snd)
         WriteLine(file, "exp_fulapp=" + exp_fulapp)
         WriteLine(file, "exp_modal=" + exp_modal)
         WriteLine(file, "exp_gadselect=" + exp_gadselect)
         WriteLine(file, "fatmark=" + fatmark)
         WriteLine(file, "lastform=")
      CloseFile(file)
   EndIf

   file = ReadFile(dir_app + "visualb.ini")
      While Not Eof(file)
         zeile$ = ReadLine(file)
         separator = Instr(zeile, "=")
         Wert$ = Mid(zeile, separator + 1, -1)
   
         Select Trim(Mid(zeile, 1, separator - 1))
         Case "dir_app"
            dir_app = wert
         Case "dir_open"
            dir_open = wert
         Case "dir_img"
            dir_img = wert
         Case "dir_snd"
            dir_snd = wert
         Case "exp_fulapp"
            exp_fulapp = wert
         Case "exp_modal"
            exp_modal = wert
         Case "exp_gadselect"
            exp_gadselect = wert
         Case "fatmark"
            fatmark = wert
         Case "lastform"
            If wert = "" Or FileType(dir_open + wert) = 0
               frmfile = "unnamed"
               form = 100
               gui_makewindow(form, 400, 300, 0, 1)
               gui_drawwindow(form, 260, 60)
               
               act = 0
               FillCtrl()
            Else
               frmfile = wert
            EndIf
         End Select
      Wend
   CloseFile(file)
   LoadForm(frmfile)
   Return firststart
End Function

Function MsgBox$(msg$, typ=0, title$="Message")
;types 0=Ok, 1=Ok/Cancel, 2=Yes/No/Cancel
   If gui_Gethandle(1000) Then gui_freewindow(1000)

   ;limit title
   If Len(title) > 150 Then title = Left(title, 140) + "..."

   ;min width
   If typ = 1
      If width < 210 Then width = 210
   ElseIf typ = 2
      If width < 310 Then width = 310
   Else
      If width < 100 Then width = 100
   EndIf

   ;temp subdiv
   originalmsg$ = msg
   j = 1
   pos = Instr(msg, Chr(31))
   While pos
      While pos > 150
         For i = 150 To 1 Step -1
            pos = Instr(msg, " ", i)
            If pos < 150 Then Exit
         Next
         tmp$ = Left(msg, pos)
         If width < StringWidth(tmp) Then width = StringWidth(tmp)
         msg = Right(msg, Len(msg) - pos)
         pos = Instr(msg, Chr(31))
         j = j + 1
      Wend

      tmp = Left(msg, pos - 1)
         If width < StringWidth(tmp) Then width = StringWidth(tmp)
      msg = Right(msg, Len(msg) - pos)
      pos = Instr(msg, Chr(31))
      j = j + 1
   Wend

   If msg <> ""
      While Len(msg) > 150
         For i = 150 To 1 Step -1
            pos = Instr(msg, " ", i)
            If pos < 150 Then Exit
         Next
         tmp = Left(msg, pos)
         If width < StringWidth(tmp) Then width = StringWidth(tmp)
         msg = Right(msg, Len(msg) - pos)
         j = j + 1
      Wend
      If msg <> ""
         If width < StringWidth(msg) Then width = StringWidth(msg)
      EndIf
   EndIf

   If width < StringWidth(title) Then width = StringWidth(title)
   If width > GraphicsWidth() * .78  Then width = GraphicsWidth() * .78
   height = j * StringHeight(tmp) * 1.5 + 65

   gui_makewindow(1000, width + 16, height, 0, 1)
   gui_makegadget(1000, 1001, 2, 2, width + 13, 18, 7, 7, title, 1)
      gui_settypes(1001, 7, 0, 0)

   If typ = 0
      gui_makegadget(1000, 1003, width/2 - 35, height - 30, 82, 20, 1, 1, "Ok", 0)
         gui_settypes(1003, 1, 0, 0)
   ElseIf typ = 1
      gui_makegadget(1000, 1003, width/2 - 80, height - 30, 82, 20, 1, 1, "Ok", 0)
         gui_settypes(1003, 1, 0, 0)
      gui_makegadget(1000, 1004, width/2 + 15, height - 30, 82, 20, 1, 1, "Cancel", 0)
         gui_settypes(1004, 1, 0, 0)
   Else
      gui_makegadget(1000, 1003, width/2 - 130, height - 30, 82, 20, 1, 1, "Yes", 0)
         gui_settypes(1003, 1, 0, 0)
      gui_makegadget(1000, 1005, width/2 - 33, height - 30, 82, 20, 1, 1, "No", 0)
         gui_settypes(1005, 1, 0, 0)
      gui_makegadget(1000, 1004, width/2 + 65, height - 30, 82, 20, 1, 1, "Cancel", 0)
         gui_settypes(1004, 1, 0, 0)
   EndIf

   ;actual subdiv
   msg = originalmsg
   j = 1
   pos = Instr(msg, Chr(31))
   While pos
      While pos > 150
         For i = 150 To 1 Step -1
            pos = Instr(msg, " ", i)
            If pos < 150 Then Exit
         Next
         tmp = Left(msg, pos)
         gui_makegadget(1000, 1010 + j, 4, 10 + j * 15, width + 10, 15, 7, 8, tmp, 1)
         msg = Right(msg, Len(msg) - pos)
         pos = Instr(msg, Chr(31))
         j = j + 1
      Wend

      tmp = Left(msg, pos - 1)
      gui_makegadget(1000, 1010 + j, 4, 10 + j * 15, width + 10, 15, 7, 8, tmp, 1)
      msg = Right(msg, Len(msg) - pos)
      pos = Instr(msg, Chr(31))
      j = j + 1
   Wend

   If msg <> ""
      While Len(msg) > 150
         For i = 150 To 1 Step -1
            pos = Instr(msg, " ", i)
            If pos < 150 Then Exit
         Next
         tmp = Left(msg, pos)
         gui_makegadget(1000, 1010 + j, 4, 10 + j * 15, width + 10, 15, 7, 8, tmp, 1)
         msg = Right(msg, Len(msg) - pos)
         j = j + 1
      Wend
      If msg <> ""
         gui_makegadget(1000, 1010 + j, 4, 10 + j * 15, width + 10, 15, 7, 8, msg, 1)
      EndIf
   EndIf

   gui_drawwindow(1000, GraphicsWidth()/2 - width/2, GraphicsHeight()/2 - height/2)
   
   Repeat
      Cls
      gadsel = gui_update(1000)
      Flip

      If gadsel=1003 Or gadsel=1004 Or gadsel=1005 Or KeyHit(28) Or KeyHit(1)
         FlushKeys
         FlushMouse
         waitformouse
         gui_freewindow(1000)

         If gadsel = 1003 Or KeyDown(28)      ;ok-yes-ENTER
            Return 1
         ElseIf gadsel = 1004 Or KeyDown(1)   ;cancel-ESC
            Return 0
         ElseIf gadsel = 1005            ;no
            Return 2
         EndIf
      EndIf
   Forever
End Function

Function SaveForm(fn$)
   If fn <> "tempfile" Then frmfile = fn
   file = WriteFile(dir_open + fn)
      WriteLine(file, "cyclic_ids=" + cyclic_ids)
      WriteLine(file, "ctrlpos=" + ctrlpos)
      WriteLine(file, "form=" + form)
      WriteLine(file, "w_x=" + gui_getwinx(form))
      WriteLine(file, "w_y=" + gui_getwiny(form))
      WriteLine(file, "w_width=" + gui_getwinw(form))
      WriteLine(file, "w_height=" + gui_getwinh(form))
      WriteLine(file, "w_type=" + GetWinType(form))
      WriteLine(file, "w_img=" + formimg)
      WriteLine(file, "w_text=" + GetWinText(form))
      WriteLine(file, "w_align=" + GetAlign(form))

      For g.gad = Each gad
         WriteLine(file, "gadget=" + gid)
         WriteLine(file, "noclick=" + g
oclick)
         WriteLine(file, "rightclick=" + gightclick)
         WriteLine(file, "inputgadget=" + ginputgadget)
         WriteLine(file, "slider_in=" + gslider_in)
         WriteLine(file, "vertical=" + gvertical)
         WriteLine(file, "x=" + gui_getx(gid))
         WriteLine(file, "y=" + gui_gety(gid))
         WriteLine(file, "width=" + gui_getw(gid))
         WriteLine(file, "height=" + gui_geth(gid))
         WriteLine(file, "mode=" + gui_getmode(gid))
         WriteLine(file, "nt=" + gui_gettype(gid))
         WriteLine(file, "ot=" + GetOverType(gid))
         WriteLine(file, "dt=" + GetDownType(gid))
         WriteLine(file, "text=" + gui_gettext(gid))
         WriteLine(file, "align=" + GetAlign(gid))
         WriteLine(file, "ni=" + g
i)
         WriteLine(file, "oi=" + goi)
         WriteLine(file, "di=" + gdi)
         WriteLine(file, "os=" + gos)
         WriteLine(file, "ds=" + gds)
      Next
   CloseFile(file)

   AppTitle frmfile + " - VisualB"
   gui_settext(57, frmfile, 1)
   gui_redrawwindow(1)
End Function

Function SaveINI()
   file = WriteFile(dir_app + "visualb.ini")
      WriteLine(file, "dir_app=" + dir_app)
      WriteLine(file, "dir_open=" + dir_open)
      WriteLine(file, "dir_img=" + dir_img)
      WriteLine(file, "dir_snd=" + dir_snd)
      WriteLine(file, "exp_fulapp=" + exp_fulapp)
      WriteLine(file, "exp_modal=" + exp_modal)
      WriteLine(file, "exp_gadselect=" + exp_gadselect)
      WriteLine(file, "fatmark=" + fatmark)

      If frmfile = "unnamed"
         WriteLine(file, "lastform=")
      Else
         WriteLine(file, "lastform=" + frmfile)
      EndIf
   CloseFile(file)
End Function

Function SetFormID(nf)
;1000 used for MsgBox, 1-99 for CtrlWin
   If nf = 1000 Or nf = 1001 Or nf < 100
      MsgBox(nf + " can't be used as new form ID. Values < 100, and 1000/1001 are reserved. Going back to " + form, 0, "Change form ID...")
      nf = form
   EndIf
   act = 0

   For g.gad = Each gad
      oldid = gid         ;save old ID
      gid = gid - form      ;remove form-offset
      gid = gid + nf      ;add new form-offset

         ;ch

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal