Author Topic: InForm Question  (Read 2567 times)

0 Members and 1 Guest are viewing this topic.

Offline Rich

  • Newbie
  • Posts: 8
    • View Profile
InForm Question
« on: January 23, 2020, 06:39:59 pm »
I am confused as to where to place my code after I have created and a form in Inform. There seems to be many places to put the code. Is there a template available to show what control subroutine (in QB64) relates to a specific control. I hope this makes some sense.

Marked as best answer by Rich on January 27, 2020, 05:06:19 am

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: InForm Question
« Reply #1 on: January 24, 2020, 04:36:07 pm »
Hi Rich
in my little experience I can affirm that Inform follows the model of event programming....
so
1.you must divide your program in the events that happen
2. then you can decide where write and what  write

here just a dummy example/demonstration

Code: QB64: [Select]
  1. ': This program uses
  2. ': InForm - GUI library for QB64 - v1.1
  3. ': Fellippe Heitor, 2016-2019 - fellippe@qb64.org - @fellippeheitor
  4. ': https://github.com/FellippeHeitor/InForm
  5. '-----------------------------------------------------------
  6.  
  7. ': Controls' IDs: ------------------------------------------------------------------
  8. DIM SHARED Template AS LONG
  9. DIM SHARED QuitBT AS LONG
  10. DIM SHARED OutputLB AS LONG
  11. DIM SHARED InputTB AS LONG
  12.  
  13. ': External modules: ---------------------------------------------------------------
  14. '$INCLUDE:'InForm\InForm.ui'
  15. '$INCLUDE:'InForm\xp.uitheme'
  16. '$INCLUDE:'Template.frm'
  17.  
  18. ': Event procedures: ---------------------------------------------------------------
  19. SUB __UI_BeforeInit
  20. 'here you can write all you need Before Initialization of Inform system
  21.  
  22. SUB __UI_OnLoad
  23. 'Here you can write all settings that are permanent at starting /and during the execution of program
  24. ' and also all resources that you need to pre-load before your program starts
  25.  
  26. SUB __UI_BeforeUpdateDisplay
  27.     'This event occurs at approximately 30 frames per second.
  28.     'You can change the update frequency by calling SetFrameRate DesiredRate%
  29.  
  30.  'here you can write all those actions that must be repeated in loop with 30 fps speed
  31.  
  32.  
  33. SUB __UI_BeforeUnload
  34.     'If you set __UI_UnloadSignal = False here you can
  35.     'cancel the user's request to close.
  36. ' here you can FREE memory from data /images/sound etc OR perform emergency saving
  37.  
  38. SUB __UI_Click (id AS LONG)
  39. 'Here you can manage the click event
  40. ' the pre_built Select Case let you distinguish among the different objects
  41.     SELECT CASE id
  42.         CASE Template
  43.                  Text(InputTB) = ""
  44.         CASE DoBT
  45.                 Caption(OutputLB) = Text(InputTB)  
  46.         CASE QuitBT
  47.  
  48.         CASE OutputLB
  49.  
  50.         CASE InputTB
  51.  
  52.     END SELECT
  53.  
  54. SUB __UI_MouseEnter (id AS LONG)
  55.     SELECT CASE id
  56.         CASE Template
  57.  
  58.         CASE DoBT
  59.  
  60.         CASE QuitBT
  61.  
  62.         CASE OutputLB
  63.  
  64.         CASE InputTB
  65.  
  66.     END SELECT
  67.  
  68. SUB __UI_MouseLeave (id AS LONG)
  69.     SELECT CASE id
  70.         CASE Template
  71.  
  72.         CASE DoBT
  73.  
  74.         CASE QuitBT
  75.  
  76.         CASE OutputLB
  77.  
  78.         CASE InputTB
  79.  
  80.     END SELECT
  81.  
  82. SUB __UI_FocusIn (id AS LONG)
  83.     SELECT CASE id
  84.         CASE DoBT
  85.  
  86.         CASE QuitBT
  87.  
  88.         CASE InputTB
  89.  
  90.     END SELECT
  91.  
  92. SUB __UI_FocusOut (id AS LONG)
  93.     'This event occurs right before a control loses focus.
  94.     'To prevent a control from losing focus, set __UI_KeepFocus = True below.
  95.     SELECT CASE id
  96.         CASE DoBT
  97.  
  98.         CASE QuitBT
  99.  
  100.         CASE InputTB
  101.  
  102.     END SELECT
  103.  
  104. SUB __UI_MouseDown (id AS LONG)
  105.     SELECT CASE id
  106.         CASE Template
  107.  
  108.         CASE DoBT
  109.  
  110.         CASE QuitBT
  111.  
  112.         CASE OutputLB
  113.  
  114.         CASE InputTB
  115.  
  116.     END SELECT
  117.  
  118. SUB __UI_MouseUp (id AS LONG)
  119.     SELECT CASE id
  120.         CASE Template
  121.                  Text(InputTB) = ""  
  122.         CASE DoBT
  123.                  Caption(OutputLB) = Text(InputTB)
  124.         CASE QuitBT
  125.                  SYSTEM
  126.         CASE OutputLB
  127.  
  128.         CASE InputTB
  129.  
  130.     END SELECT
  131.  
  132. SUB __UI_KeyPress (id AS LONG)
  133.     'When this event is fired, __UI_KeyHit will contain the code of the key hit.
  134.     'You can change it and even cancel it by making it = 0
  135.     SELECT CASE id
  136.         CASE DoBT
  137.  
  138.         CASE QuitBT
  139.  
  140.         CASE InputTB
  141.  
  142.     END SELECT
  143.  
  144. SUB __UI_TextChanged (id AS LONG)
  145.     SELECT CASE id
  146.         CASE InputTB
  147.  
  148.     END SELECT
  149.  
  150. SUB __UI_ValueChanged (id AS LONG)
  151.     SELECT CASE id
  152.     END SELECT
  153.  
  154. SUB __UI_FormResized
  155.  
  156.  
  157.  
Programming isn't difficult, only it's  consuming time and coffee

FellippeHeitor

  • Guest
Re: InForm Question
« Reply #2 on: January 24, 2020, 05:27:04 pm »
As TempodiBasic exemplified, the .bas file that InForm saves is your template. Each SUB is an event (Click, OnLoad, ValueChanged, etc) and in each sub you’ll find your controls’ name to write code for.

Code: QB64: [Select]
  1.  SUB __UI_Click (id AS LONG)
  2.     SELECT CASE id
  3.         CASE control1
  4.                  'Enter code here for when control1 is clicked
  5.         CASE control2
  6.                  'Enter code here for when control2 is clicked
  7.         CASE control3
  8.                  'Enter code here for when control3 is clicked and etc
  9.     END SELECT

Offline Rich

  • Newbie
  • Posts: 8
    • View Profile
Re: InForm Question
« Reply #3 on: January 27, 2020, 10:00:53 am »
Thank you!