Back to V FAQ Top

# V FAQ (V CLASSES)

- About vAppWinInfo class
- How to use vTimer

## About vAppWinInfo class

Q:
  How do you use the vAppWinInfo class? An example?

  A:

  Well, vAppWinInfo largely turns out to be useless. It was intended for MVC apps, but it doesn't work for that very well.

  Beginning with V 1.21, the functions vApp::UpdateAllViews and vWindow::UpdateView have been added to help support MVC. See vApp in the Reference manual for a better discussion.

  ## How to use vTimer

  Q:
  I want to call a screen update every few seconds. Is it best to call the routine from within the TimerTick routine, or send an update event to the cmdwin ?

  A:

  The key to coordinating a timer with a window is to create the timer object from the command window, and pass the 'this' of the command window to the timer. The timer then uses the pointer to the command window to call the WindowCommand method of that window object to do whatever is needed on the timer event.

  Consider the following code excerpts:

         // Derive a simple timer class that allows a command window
         // pointer to be passed in.
         class myCmdWindow;   // Whatever you command window class is
         class myTimer : public vTimer
            {
            public:           //---------------------------------------- public
              myTimer(myCmdWindow* cw) { cmdw = cw; }
              ~myTimer() {}
              virtual void TimerTick()
                 // Call the window's WindowCommand to respond to the timer
      	   {cmdw->WindowCommand(appropriateID, appropriateID, C_Button);}
            private:          //--------------------------------------- private
              myCmdWindow* cmdw;
            };

         // Then, in the command window

      //================>>> myCmdWindow::myCmdWindow <<<================
        myCmdWindow::myCmdWindow(char* name, int height, int width) :
          vCmdWindow(name, height, width)
        {
          // Appropriate stuff to define window
          // ...

          // Now, create the timer to local myTimer _timer ptr.

          _timer = new myTimer(this);         // create timer
          _timer->TimerSet(1000);             // 1 second interval

          // ....
         }