Microsoft KB Archive/106661

= How to Determine the Shape of the Mouse Cursor =

Article ID: 106661

Article Last Modified on 12/3/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft FoxPro 2.5b
 * Microsoft FoxPro 2.5a
 * Microsoft FoxPro 2.5b

-



This article was previously published under Q106661



SUMMARY
In FoxPro for Windows, the cursor (mouse pointer) can change shape depending on where it is located on the screen. There isn't a function in FoxPro that tells you the current shape of the cursor. The code example below shows one method of determining the cursor's shape.



MORE INFORMATION
Several functions in the Microsoft Windows Software Development Kit (SDK) can be used to control and get information about the current Windows cursor. The two that this program (IBEAM.PRG) uses are LoadCursor and GetCursor. The REGFN and CALLFN routines within FOXTOOLS.FLL are used to call the SDK cursor functions. * IBEAM.PRG starts here:

#DEFINE idc_arrow      (32512) #DEFINE idc_ibeam      (32513) #DEFINE idc_wait       (32514) #DEFINE idc_cross      (32515) #DEFINE idc_uparrow    (32516) #DEFINE idc_size       (32640) #DEFINE idc_icon       (32641) #DEFINE idc_sizenwse   (32642) #DEFINE idc_sizenesw   (32643) #DEFINE idc_sizewe     (32644) #DEFINE idc_sizens     (32645)

SET LIBRARY TO SYS(2004)+'foxtools.fll'

* Register the LoadCursor function to find out the resource * number for IDC_IBEAM.

fnhand=regfn('LoadCursor',"IL","I") cursor_res=callfn(fnhand,0,idc_ibeam)

* Find out what the current cursor resource number is.

fn2hand=regfn('GetCursor',"","I") CURSOR=callfn(fn2hand)

* Test to see if the current cursor resource number equals * that of IDC_IBEAM (or whatever we change it to).

IF cursor_res = CURSOR WAIT WINDOW "That's the I-Beam Cursor!" ELSE WAIT WINDOW "That's not an I-Beam Cursor!" ENDIF To run IBEAM.PRG, type the following line in the Command window. When you press F4, IBEAM.PRG will be called and will tell you whether the cursor is in the I-beam shape or not, depending on the position of the mouse.

ON KEY LABEL F4 DO IBEAM.PRG

