Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- FreshWin (c) Fresh Technologies - <b>getevent() event function</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
  GETEVENT()                                                  Event Function
 Purpose..: Return a window event array
-------------------------------------------------------------------------------
 Syntax...: GetEvent( [<nSeconds>[, <lClearPress>]] ) --> aRayMsg

 Arguments: [<nSeconds>]     = specifies the number of seconds
                               GetEvent() waits for a key or mouse press.
                               The value can be specified in increments
                               as small as 1/10 of a second. Specifying
                               0 halts the program until a key or mouse
                               press is detected. If <nSeconds> is omitted,
                               GetEvent() does not wait at all but will
                               return the window event array composed of
                               what is in the keyboard or mouse
                               queue in the same way that inkey() returns
                               the ASCII code from the keyboard buffer.

           [<lClearPress>]  = if a mouse press is detected. The
                              parameter will make sure that all mouse
                              presses are cleared before continuing. The
                              parameter is important particularly for those
                              times when you want to make sure that the
                              mouse has been released before retrieving
                              the press information.

 Returns..: <A> aRayMsg is a four element array. The second element,
            defined by the mainfest constant E_WIN, specifies the window
            in which the event has occurred. If there are no windows in
            use, aRayMsg[ E_WIN ] will contain an empty array. It will always
            be the window in focus unless a mouse press was sensed in an
            active window that is not in focus. Keyboard events always
            occur in the window that has focus. Once aRayMsg is returned,
            you must decide whether you want to process or ignore the
            message. The responsibility is yours.

            The chart shows the correlation between the elements
            of aRayMsg[] ( shown horizontally ) and their values
            ( shown vertically ). E_WIN will contain a reference to the
            window structure in which the event occurred.

            Manifest Constants as found in FW_EVENT.CH
            ------------------------------------------------------
            E_MSG          E_P1              E_P2      E_P3
            ------------------------------------------------------
            FWM_NONE       0                 0         0
            FWM_KEYBOARD   Key value         0         0
            FWM_MOUSE      button pressed    MouseRow  MouseColumn
            FWM_SETKEY     action key block  0         0
            FWM_CLOSE      0                 0         0
            FWM_MIN        0                 0         0
            FWM_MAX        0                 0         0
            FWM_MOVE       0                 0         0
            FWM_SIZE       0                 0         0
            ------------------------------------------------------

 Source...: GETEVENT.PRG
-------------------------------------------------------------------------------
 Example..: . The example takes an event from getEvent() and
            adds vertical scroll bar information to it.

            #include "fresh.ch"

            *-- Main event loop
            aMsg := getEvent()

            if !( aMsg[ E_MSG ] == FWM_NONE )

               // Process standard window messages
               do case
               case aMsg[ E_MSG ] == FWM_KEYBOARD
                  nEvent := sbGetEvent( aVSB, aHSB, aMsg[ E_P1 ] )

               case aMsg[ E_MSG ] == FWM_MOUSE
                  nEvent := sbGetEvent( aVSB, aHSB, 0,;
                                        aMsg[ E_P1 ], ;
                                        aMsg[ E_P2 ], ;
                                        aMsg[ E_P3 ]  )

               endcase
            endif

See Also: MsInkey()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson