help user32 userlib

Blitz3D Forums/Blitz3D Userlibs/help user32 userlib

mongia2(Posted 2005) [#1]
Hi all,
I've try to use the user32 userlib but many functions in it
need uses of pointers, for example, if I would know the position
of mouse cursor using api_GetCursorPos%(lpPoint*) how I should use the pointer to get the X and Y coords???

Thanks All for help,
mongia2


turtle1776(Posted 2005) [#2]
In general, the first thing I do in these situations is search on Google to pull up the MSDN documentation on the command, which in this case is here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/resources/cursors/cursorreference/cursorfunctions/getcursorpos.asp

In this case, the command takes a pointer, as you noted. The documentation says it needs a pointer to a Point structure, and provides a link. If you click that link, you will see that the structure is two longs, which are the same as integers.

So, to make it work, you need to do something like this (I haven't tested, but it should work):

lpPoint = createbank(8);big enough to handle two integers
result = api_GetCursorPos%(lpPoint)
if result = 1 ;if it worked
   x = peekint(lpPoint,0)
   y = peekint(lpPoint,4)
end if
freebank lpPoint

For another working example, see TotalSysMem() and AvailSysMem() at the bottom of this code archive entry:
www.blitzbasic.com/codearcs/codearcs.php?code=1233