How to Trap the Double Mouse Click on a Field

Last reviewed: April 17, 1995
Article ID: Q95292
The information in this article applies to:
  • Microsoft FoxPro for MS-DOS, version 2.0

The following program traps the double mouse click on a GET field and displays the results in a WAIT WINDOW.

   CLEAR
   CLEAR ALL
   USE customer
   @2,2 GET contact
   @4,2 GET company WHEN one() VALID two()
   *** Enables ON KEY LABEL when the field is entered and
   *** disables it upon exit
   @6,2 GET city
   READ CYCLE
   ON KEY LABEL LEFTMOUSE

   PROCEDURE one
     ON KEY LABEL LEFTMOUSE DO three
     RETURN .T.

   PROCEDURE two
     ON KEY LABEL LEFTMOUSE
     RETURN

   PROCEDURE three
     ON KEY LABEL LEFTMOUSE
     SET TALK OFF
     y = INKEY ("MH")               && Checks for mouse click.
     x = INKEY (_DBLCLICK,"MH")     && Checks for double mouse click.

     IF x = 151
          row = MROW()       && Checks row where mouse was clicked.
          col = MCOL()       && Checks column where mouse was clicked.
          IF row = 4                   && Row of GET field.
              IF col > 1 AND col < 21      && Location of GET field.
                    WAIT WINDOW "Double"
                    _CUROBJ=OBJNUM(contact)
                    RETURN
                    EXIT
              ENDIF
          ENDIF
     ELSE
          row = MROW()       && Checks row where mouse was clicked.
          col = MCOL()       && Checks column where mouse was clicked.
          IF row = 4         && Row of GET field.
               IF col > 1 AND col < 21      && Location of GET field.
                    x=''
                    @ MROW(),MCOL() GET x WHEN x = 151
                    WAIT WINDOW "Single"
               ENDIF
          ENDIF
     ENDIF

     ON KEY LABEL LEFTMOUSE DO three
     RETURN

NOTE: A single mouse click no longer works while the cursor is on this field. To leave the field, press the TAB or ENTER key.


Additional reference words: FoxDos 2.00 double-click
KBCategory: kbprg kbcode
KBSubcategory:


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 17, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.