Author Topic: Some Questions Regarding Inform Development  (Read 286 times)

0 Members and 1 Guest are viewing this topic.

Offline MLambert

  • Forum Regular
  • Posts: 113
Some Questions Regarding Inform Development
« on: August 24, 2020, 09:17:04 PM »
Hi,

Just a couple of questions …..

How do I make a field display only .. show an error message

How do I create a date mask in a field  .. DD/MM/YYYY

If I want a field 30 Characters wide .. what do I make the field length

How do I start the form off in the middle of the screen

How do I include my own code as part of the build

How do I set focus for a field. When the form starts I want the cursor in a particular field (which may not be the first field)

What is tool tips ?

Why does QB64 start when I am displaying a form ?

I have found ‘old’ fields hidden under new fields .. can I find these ‘hidden’ fields easily or do I have to move every field to see if there is another field underneath it

Why doesn’t the Inform generate code for each field
I have 40 + fields but the code produced shows only..

SUB __UI_Click (id AS LONG)
    SELECT CASE id
        CASE formgainlinedataentry

        CASE enterTeamNameTB

        CASE player1SurnameTB

    END SELECT

Mike

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 672
  • If you're API and you know it clap your hands
    • My GitHub
Re: Some Questions Regarding Inform Development
« Reply #1 on: August 24, 2020, 09:44:39 PM »
Here are the best answers I have for you:


Quote
What is tool tips ?
Tool tips are little message boxes that display when your mouse hovers over a field in a program window. For instance, when you hover your mouse over a program in your task bar and it shows the name of the program under your cursor.
 



Quote
How do I include my own code as part of the build
You will put the code that you want executed in the event that will call it. For instance, if you want to print a file when someone presses a button called "Print" on your form, you would need to put the code that would handle the printing in the __UI_Click sub under the CASE for the name of the button. For instance,
Code: QB64: [Select]
  1. SUB __UI_Click (id AS LONG)
  2.      SELECT CASE id
  3.           CASE PrintBT
  4.           'do printing code
  5.      END SELECT


Quote
If I want a field 30 Characters wide .. what do I make the field length
This is dependent on font size and font family. You can check this in the preview by changing the caption to some example text and seeing how it fits once you change to the desired font and size.


Quote
How do I set focus for a field. When the form starts I want the cursor in a particular field (which may not be the first field)
In the editor, there is an option for Z-ordering.
 

This allows you to set the order in which the focus is set in when you are doing things like tab. You should also be able to set focus like this:
Code: QB64: [Select]
  1. SUB __UI_OnLoad
  2.      SetFocus TextBox1


Quote
Why doesn’t the Inform generate code for each field
I have 40 + fields but the code produced shows only..
You probably saved the form and then added more fields to it. Look at the top of the BAS code generated by InForm and you will see this:
Code: QB64: [Select]
  1. REM NOTICE: THIS FORM HAS BEEN RECENTLY EDITED
  2. '>> The controls in the list below may have been added or renamed,
  3. '>> and previously existing controls may have been deleted since
  4. '>> this program's structure was first generated.
  5. '>> Make sure to check your code in the events SUBs so that
  6. '>> you can take your recent edits into consideration.
You will need to follow the syntax of the other controls that were there and add the new ones to your BAS code in the events that will be calling them. For instance, if they are buttons then you probably want them in the __UI_Click sub.


Quote
How do I start the form off in the middle of the screen

That, or in the __UI_OnLoad sub do this:
Code: QB64: [Select]


Quote
Why does QB64 start when I am displaying a form ?
It isn't starting when you are editing a form. The icon you are seeing in the bottom is from the preview form having the same icon as the IDE. The only time QB64 actually starts from InForm is when you press save and it asks if you want to exit to QB64.


Quote
How do I make a field display only .. show an error message
With this, are you wanting it to display a QB64 error or a custom error that you are determining in your code? If you are wanting to show an actual QB64 error, here is some code for that:
Code: QB64: [Select]
  1. '....
  2. DIM SHARED TextBox1 AS LONG
  3. DIM SHARED ErrorLog AS STRING
  4.  
  5. ON ERROR GOTO HANDLER
  6. HANDLER:
  7.     ErrorLog = "Error code " + _TRIM$(STR$(ERR)) + " on line " + _TRIM$(STR$(_ERRORLINE))
  8.     RESUME NEXT
  9.  
  10. ': External modules: ---------------------------------------------------------------
  11. '$INCLUDE:'InForm\InForm.ui'
  12. '$INCLUDE:'InForm\xp.uitheme'
  13. '$INCLUDE:'mlamberthelp.frm'
  14.  
  15.  
  16. ': Event procedures: ---------------------------------------------------------------
  17. SUB __UI_BeforeInit
  18.  
  19.  
  20. SUB __UI_OnLoad
  21.     ERROR 97 'or whatever error you are wanting to display. I'm just invoking one manually.
  22.  
  23. SUB __UI_BeforeUpdateDisplay
  24.     'This event occurs at approximately 30 frames per second.
  25.     'You can change the update frequency by calling SetFrameRate DesiredRate%
  26.     IF ErrorLog <> "" THEN
  27.         Text(TextBox1) = ErrorLog
  28.         ErrorLog = ""
  29.     END IF
  30. '....
And a screenshot:
 

Make sure you put the ON ERROR just below the DIM SHARED so you can have it in the main module.


Quote
How do I create a date mask in a field  .. DD/MM/YYYY
On short notice, this is what I came up with. In the __UI_TextChanged sub, put something along these lines:
Code: QB64: [Select]
  1. SUB __UI_TextChanged (id AS LONG)
  2.     SELECT CASE id
  3.         CASE TextBox1
  4.             IF LEN(Text(TextBox1)) = 8 THEN
  5.                 Text(TextBox1) = MID$(Text(TextBox1), 1, 2) + "/" + MID$(Text(TextBox1), 3, 2) + "/" + MID$(Text(TextBox1), 5, 4)
  6.             END IF
  7.     END SELECT
« Last Edit: August 25, 2020, 12:38:13 AM by SpriggsySpriggs »

Offline MLambert

  • Forum Regular
  • Posts: 113
Re: Some Questions Regarding Inform Development
« Reply #2 on: August 24, 2020, 11:32:29 PM »
Wonderful.

Many Thanks,

Mike

Offline MLambert

  • Forum Regular
  • Posts: 113
Re: Some Questions Regarding Inform Development
« Reply #3 on: August 24, 2020, 11:52:58 PM »
One more ...

where do I find  this call and others ??  __UI_FocusIn(TextBox) ...

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 672
  • If you're API and you know it clap your hands
    • My GitHub
Re: Some Questions Regarding Inform Development
« Reply #4 on: August 25, 2020, 12:31:07 AM »
I was actually wrong about the focus thing.... I edited my original reply with the correct way to set the focus.

Here is the actual way to do it:
Code: QB64: [Select]
  1. SetFocus TextBox1 'or whatever the name of the field is

Check out the Wiki for InForm to see more info.
https://github.com/FellippeHeitor/InForm/wiki

As for seeing all the calls and subs, you really just need to scroll through the code generated by InForm. Each sub is labeled with the event that it handles. As long as you put your code in the correct events for the correct fieldnames then the program will run just fine.
« Last Edit: August 25, 2020, 12:35:57 AM by SpriggsySpriggs »