Announcement

Collapse
No announcement yet.

Displaying a form in its initialized state

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Displaying a form in its initialized state

    Perhaps this has been asked and answered before, but I couldn't find it with search. I want to display a form in its initial form, i.e. the same form it would appear after a power up. Currently, if I show a form A, then do some updates to widgets, then show form B, then show form A again, the widgets on form A are in the state I left them. This is OK most of the time, but there are times when I'd like to show the form in its initial state, so that I don't have to re-initialize everything (some of my forms have 40 widgets on them). I'd just like to display the form in its as-designed known state. Is there a method for doing this?

  • #2
    Hello CDAVIS2747,

    Can I ask on what Workshop4 environment are you currently using on this project? The state of the widgets depends on the image index of the widgets, they will retain their last state if they are not changed/toggled when switching forms.

    In the ViSi environment, I can suggest using for-loop statement to re-initialize the widgets on the form (assuming those widgets has an initial state of 0). You can use this when you are switching back to form A.
    Code:
    for ( i := 0 ; i < 40 ; i++ )
           img_SetWord(hndl, i , IMAGE_INDEX, 0);
           img_Show(hndl, i ) ;
    next

    Comment


    • CDAVIS2747
      CDAVIS2747 commented
      Editing a comment
      I'm speaking specifically of the Visi-Genie environment. I realize I can have the host send messages to initialize all the widgets on the form, but that would amount to a large number of messages and probably a lot of time. I was hoping there was some way to just force the load of a "virgin" copy of the form just like you do when it is loaded for the first time, rather than have to send messages to initialize 40 different items. I could have the processor do a hard reset of the display, but that seems rather crude and would take additional time also.

  • #3
    if you are using visi genie environment, you can use the handler to reinitialize whatever you want when a specific form is opened as well.

    Tony

    Comment


    • #4
      Hello CDAVIS2747,

      If you are currently using the Pro version of the Workshop4 IDE, you can implement this within the display without having the host send commands, by writing a magic event for re-initializing all the widgets upon changing form.

      Code:
      func MagicEvent1(var newval)
      
      for (ObjectIndex := 0; ObjectIndex < 40; ObjectIndex++)
           WriteObject(tobjectA, ObjectIndex , 0);
      next
      
      for (ObjectIndex := 0; ObjectIndex < 40; ObjectIndex++)
           WriteObject(tobjectB, ObjectIndex , 0);
      next
      ...
      endfunc
      Last edited by Jerson; 7th December 2017, 04:41 PM.

      Comment


      • #5
        Thanks Jerson, I just got the pro version two days ago, so I haven't had much time to dig into it, but I see what you are saying. I assume the "magic event" can be triggered via a message of some sort? Or does it just run automatically at some point in the flow of events? The key thing is that sometimes I want to load the form in its last state, and sometimes I want an initialized copy, so I'd like to have control over when this event does or does not get run.

        Comment


        • #6
          OK, I got it working. Just set up one magic object with code to initialize all the widgets to the desired state, then send a message to the magic object and all is done in a flash. Thanks!

          Comment

          Working...
          X