BUG: MOUSE(0) with WINDOW OUTPUT Gives Incorrect Coordinates (79118)
The information in this article applies to:
- Microsoft QuickBASIC Compiler for the Apple Macintosh 1.0
- Microsoft QuickBASIC Compiler for the Apple Macintosh 1.0a
- Microsoft QuickBASIC Compiler for the Apple Macintosh 1.0b
This article was previously published under Q79118 SYMPTOMS
In a compiled program, the MOUSE function incorrectly returns the
position of the mouse pointer relative to the output window rather
than the active window. This problem only occurs in compiled programs
that use the WINDOW OUTPUT statement to direct output to a window
other than the active window.
Microsoft has confirmed this to be a bug in Microsoft QuickBasic
versions 1.0, 1.0a, and 1.0b for Macintosh . We are researching
this problem and will post new information here as it becomes
available.
MORE INFORMATIONWorkaround
To work around this problem, set the output window to the active
window using the WINDOW OUTPUT statement before calling MOUSE(0).
The function MOUSE(0) is designed to return the status of the mouse
button and record the position of the mouse pointer within the active
window. The x and y coordinates recorded by MOUSE(0) are returned by
MOUSE(1) and MOUSE(2), respectively.
The active window is the highlighted, front-most window. It is the
same as the output window unless the WINDOW OUTPUT statement is used
to direct output to another window.
Steps to Reproduce Problem
The program example below demonstrates the problem. The program
creates two windows titled "One" and "Two". When you press the mouse
button while the mouse pointer is in window "One," the mouse pointer x
and y coordinates are printed in window "Two."
When run in the interpreter environment, the x and y coordinates are
correctly relative to the upper-left corner of window "One." When
compiled, the coordinates are incorrectly relative to the upper-left
corner of window "Two" (the values printed are negative).
WINDOW 1, "One", (10, 40)-(250, 160), 1
WINDOW 2, "Two", (250, 190)-(500, 320), 1
WINDOW 1 ' the active window
WINDOW OUTPUT 2 ' the output window
WHILE INKEY$ = ""
IF MOUSE(0) <> 0 THEN ' mouse button down
PRINT "x="; MOUSE(1); "y="; MOUSE(2)
END IF
WEND
END
To work around the problem so that this compiled program behaves
correctly, insert the statement "WINDOW OUTPUT 1" before the statement
"IF MOUSE(0) ..." and insert "WINDOW OUTPUT 2" before the statement
"PRINT "x=" ..."
Modification Type: | Major | Last Reviewed: | 10/20/2003 |
---|
Keywords: | kbbug KB79118 |
---|
|