[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
   WM_BUTTON ..
   Cursor positions and keyboard status flags
------------------------------------------------------------------------------

    The WM_xBUTTONx messages are sent when the user presses, releases
    or doubleclicks mouse buttons or when he hits a keyboard button.
    WINDOWS sends a _lot_ of this kind of message. A typical DoubleClick 
    with the left mouse button results in four WM_xBUTTONx Messages:

    WM_LBUTTONDOWN       /* Button goes down */
    WM_LBUTTONUP         /* and gets released */
    WM_LBUTTONDBLCLK     /* pressed again in DoubleClick time */
    WM_LBUTTONUP         /* and finally released again */

    Every one of this messages is passed up to clipper level and can
    be used to trigger special events ( who says Clipper is slow ? ).
    Here are the messages and their FiveWin counterparts :
    
  +------------------------------------------------------------------------+
  | Message            ActionBlock    SendMethod    Send when              |
  |------------------------------------------------------------------------|
  | WM_LBUTTONDOWN   | bLClicked    | LButtonDown | Left Button is pressed |
  | WM_LBUTTONUP     | bLButtonUp   | LButtonUp   | "             released |
  | WM_LBUTTONDBLCLK | bLDblClick   | LDblClick   | "        DoubleClicked |
  | WM_MBUTTONDOWN   | bMButtonDown | MButtonDown |  Mid Button is pressed |
  | WM_MBUTTONUP     | bMButtonUp   | MButtonUp   | "             released |
  | WM_MBUTTONDBLCLK | --           | --          | --                     |
  | WM_RBUTTONDOWN   | bRClicked    | RButtonDown |   Right Button pressed |
  | WM_RBUTTONUP     | bRButtonUp   | RButtonUp   |               released |
  | WM_RBUTTONDBLCLK | --           |             | --                     |
  | WM_MOUSEMOVE     | bMmoved      | MouseMove   | the mouse is moved     |
  +------------------------------------------------------------------------+

  Each of this messages is attended by three arguments. They are converted
  to clipper parameters by FiveWin and then passed to the Actionblocks when
  they are evaluated ( like EVAL( bClicked, nRow, nCol, nKeyFlags )), where:


      <nRow>      is the pixel row where the mouse cursor was positioned 
                  when the mouse click occurred

      <nCol>      is the pixel column at that time

      <nKeyFlags> indicates whether virtual keys are down, and if the
                  right, left or middle mouse button was pressed also. This 
                  can be a combination of the values which have the following 
                  constant names ( in the Windows API description ) :

                   MK_LBUTTON  1 The left mouse button was pressed

                   MK_RBUTTON  2 The right mouse button was pressed
                                         
                   MK_SHIFT    4 The <Shift> key was pressed

                   MK_CONTROL  8 The <ctrl> key was pressed also

                   MK_MBUTTON 16 The middle mouse button was pressed

  
  HINTS:

  While the <nRow> and <nCol> paramters are pretty much self explaining the
  <nKeyFlags> need some interpretation. The information behind the INTEGER
  that Clipper sees are binary coded, which means that each Bit of the value
  represents a Flag that describes a certain status. You have to AND ( not 
  the logical .AND. ! ) the value, because more than one Bitflag can be set,
  so simply using : 

     +-------------------------------------------------------------+
     |  /* This is not working ! */                                |
     |  IF nKeyFlag == MK_CONTROL                                  |
     |     [ ... ]                                                 |
     |  ENDIF                                                      |
     +-------------------------------------------------------------+

  would not do the trick. Binary Flags can be checked with the Function 
  lAnd. 

  IF you want to know if the CONTROL Key was down together with the 
  mouse button, you AND the value in <nKeyFlag> with a 'Bitmask' that has
  the Bits set to 1 that you want to check.
  This value would be MK_CONTROL ( 8 ), so we use :
  
     +-------------------------------------------------------------+
     |  /* check for CONTROL - KEY   */                            |
     |  IF lAnd( MK_CONTROL, nKeyFlag )                            |
     |     MsgInfo( 'Control was pressed !' )                      |
     |  ENDIF                                                      |
     +-------------------------------------------------------------+
  
   Lets see what happens:

              nKeyFlag    12      Binary  00001100
              MK_CONTROL   8              00001000
              ------------------------------------
              12 AND 8 =   8              00001000

  Because lAnd() will return a TRUE if the result of the AND is not zero, 
  it shows that bit4 is set and that the control key was down also.




See Also: lAnd TWINDOW
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson