Microsoft KB Archive/79118

= BUG: MOUSE(0) with WINDOW OUTPUT Gives Incorrect Coordinates =

Article ID: 79118

Article Last Modified on 10/20/2003

-

APPLIES TO


 * Microsoft QuickBasic Compiler for Macintosh 1.0
 * Microsoft QuickBasic Compiler for Macintosh 1.0
 * Microsoft QuickBasic Compiler for Macintosh 1.0

-



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.



Workaround
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 &quot;One&quot; and &quot;Two&quot;. When you press the mouse button while the mouse pointer is in window &quot;One,&quot; the mouse pointer x and y coordinates are printed in window &quot;Two.&quot;

When run in the interpreter environment, the x and y coordinates are correctly relative to the upper-left corner of window &quot;One.&quot; When compiled, the coordinates are incorrectly relative to the upper-left corner of window &quot;Two&quot; (the values printed are negative). WINDOW 1, &quot;One&quot;, (10, 40)-(250, 160), 1 WINDOW 2, &quot;Two&quot;, (250, 190)-(500, 320), 1

WINDOW 1                 ' the active window WINDOW OUTPUT 2          ' the output window

WHILE INKEY$ = &quot;&quot; IF MOUSE(0) <> 0 THEN ' mouse button down PRINT &quot;x=&quot;; MOUSE(1); &quot;y=&quot;; MOUSE(2) END IF WEND END To work around the problem so that this compiled program behaves correctly, insert the statement &quot;WINDOW OUTPUT 1&quot; before the statement &quot;IF MOUSE(0) ...&quot; and insert &quot;WINDOW OUTPUT 2&quot; before the statement &quot;PRINT &quot;x=&quot; ...&quot;

Additional query words: MQuickB 1.00 1.00a 1.00b

Keywords: kbbug KB79118

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.