Is it a error about "PtInRect" declaration.

the declaration in user.inc:


but in Win32.hlp,it is declared like this:

BOOL PtInRect(

CONST RECT *lprc,// address of structure with rectangle
POINT pt // structure with point

so why and how I use it in my program?

Thanks and have a good day!

Posted on 2002-01-10 20:07:37 by smallwaves

the include files are taken directly from the Microsoft libraries which have the correct parameter count. This is one place where the Microsoft documentation is wrong, there are few API functions that use 2 co-ordinates for a point that are documented as a POINT structure but actually pass the 2 parameters directly.


Posted on 2002-01-10 23:52:05 by hutch--
Actually, the microsoft documentation is not wrong here. When you
pass a struct to a function in C, the compiler pushes the contents
of the struct, not a pointer to it. Yes, this amounts to the same as
passing the 2 parameters directly, but there *is* a difference...
imagine pushing the contents manually of a struct with many entries.
(Hopefully, no programmers would be braindead enough to pass
such structs by stack pushing ;)).
Posted on 2002-01-11 00:53:49 by f0dder
This is not quit so, when the documentation referes to the parameter as the address of a structure, normally you would pass its address to the function as is often used with RECT structures but with the POINT structure, Microsoft have been inconsistent in that the function requires the 2 paramaters passed directly on the stack, not as an address on the stack.


Posted on 2002-01-11 04:25:21 by hutch--
Hutch, there's a difference between "POINT *" (or LPPOINT) and
just "POINT". Following standard C, a structure is not a pointer, while
an array is. Thus, passing a structure (and not &structure, the pointer to
/ address off the structure) will cause the structure to be pushed.
No inconsistency at all.
Posted on 2002-01-11 05:00:41 by f0dder
I have not understood it very well but as you say,I should invoke it by pushing 4*3 bytes and then it would work well then?

Posted on 2002-01-13 04:08:22 by smallwaves
I use PtInRect that way in some of my Apps:

invoke GetWindowRect, hInbox, addr rInbox

invoke GetCursorPos, addr pt ; cursor position bekommen

invoke PtInRect, addr rInbox, pt.x, pt.y ; ist der cursor ?ber dem button?

.if (eax) ; wenn ja, dann
invoke MouseOver, hInbox ; mouseover effekt
.else ; wenn nein, dann
invoke MouseOut, hInbox ; normaler effekt

rInbox == address of a RECT
pt.x == x coordinate of a POINT
pt.y == y coordinate of a POINT

Hope this helps!
Posted on 2002-01-13 04:25:45 by bazik
Ok,I will test it.
Posted on 2002-01-13 19:58:46 by smallwaves