"Illegal Function Call" Using Graphics Cursor in UI Toolbox (79674)



The information in this article applies to:

  • Microsoft Basic Professional Development System for MS-DOS 7.1
  • Microsoft Basic Professional Development System for MS-DOS 7.0

This article was previously published under Q79674

SUMMARY

When using a mouse pointer with a graphics cursor (supported only by certain video cards), the error message "Illegal Function Call" will occur in the User Interface Demo (UIDEMO.BAS and MOUSE.BAS) when you point the mouse pointer and click on the upper right corner of the screen.

Microsoft has confirmed this to be a problem in Microsoft Basic Professional Development System (PDS) versions 7.0 and 7.1 for MS-DOS.

MORE INFORMATION

To get a graphics mouse pointer, you must have a Video Seven or Chips & Technology video card and Microsoft Mouse driver version 7.03 or later.

In the User Interface Toolbox, every time a call to the MousePoll subroutine is made, the cursor position of the mouse is returned. MousePoll returns the current X and Y pixel coordinate of the mouse divided by 8 to get the row and column number of where the mouse is positioned. (A character is 8 pixels wide and 8 pixels high.)

There is a problem with the code in the MousePoll routine. When you use a text cursor, all is fine because the maximum pixel coordinate for the row will never be more than 192, and the maximum coordinate for the column will never be more than 632. However, when you use a graphics cursor, the maximum coordinate for the row and column is 199 and 639, respectively. This will cause the return value of MousePoll to be row 26 and column 81. These bad values can cause unpredictable results throughout your program. One specific error you can get in the User Interface Demo is an "Illegal Function Call" error when you click the upper right hand corner of the screen after going through the startup screen. The following is the code in the MousePoll subroutine that will cause the problem:
   row = row / 8 + 1
   col = col / 8 + 1
				
Because you are using floating point division, the value of the row or column divided by 8 will be rounded up before 1 is added to it, and the result is assigned to the row or column variable. You can correct the problem by using the integer division symbol (\) instead of the floating-point division symbol (/). The following is the corrected code:
   row = row \ 8 + 1
   col = col \ 8 + 1
				
This change will not affect the execution of a program that will only be used with a text cursor.

Modification Type:MinorLast Reviewed:8/16/2005
Keywords:KB79674