The MASM Forum

Projects => MASM32 => WINDOWS.INC Project => Topic started by: NoCforMe on June 08, 2015, 03:48:07 PM

Title: Problem: ChildWindowFromPoint() prototype
Post by: NoCforMe on June 08, 2015, 03:48:07 PM
The prototype for ChildWindowFromPoint() in windows.inc seems to be wrong. It calls for 3 parameters, while MSDN says there are only 2 (https://msdn.microsoft.com/en-us/library/windows/desktop/ms632676(v=vs.85).aspx). And if I change the prototype, the linker complains about an unresolved reference.

Apparently this isn't one of the most popular functions used by folks here ...
Title: Re: Problem: ChildWindowFromPoint() prototype
Post by: hutch-- on June 08, 2015, 03:58:56 PM
Its a quirk of C notation, the linker is telling you the truth.
Title: Re: Problem: ChildWindowFromPoint() prototype
Post by: NoCforMe on June 08, 2015, 04:05:35 PM
I don't get it; what's the third parameter? Should it just be set to NULL? I notice all the ...WindowFrom... functions have "extra" parameters.
Title: Re: Problem: ChildWindowFromPoint() prototype
Post by: NoCforMe on June 08, 2015, 04:10:02 PM
Wait, wait, I think I get it: the 2nd parameter is a POINT structure, not the address thereof, so the 2 parms must be x and y, right? I'm going to try that now ...
Title: Re: Problem: ChildWindowFromPoint() prototype
Post by: dedndave on June 08, 2015, 07:14:31 PM
you guessed correctly

if it were prototyped as a POINT, you would have to pass a structure from memory
because Hutch has prototyped the POINT as 2 dwords, you can pass registers, if desired

there are a few other similar prototypes

SetConsoleTextAttribute is also prototyped differently, but for a different reason
it has a WORD argument, but it's prototyped as a DWORD to maintain stack alignment
Title: Re: Problem: ChildWindowFromPoint() prototype
Post by: NoCforMe on June 09, 2015, 02:32:57 PM
SetConsoleTextAttribute is also prototyped differently, but for a different reason
it has a WORD argument, but it's prototyped as a DWORD to maintain stack alignment

Well, sure, I would ASSUME* this is the way to handle all such cases where there's a word-sized thing. One could push words on the stack, I suppose, but what a mess that would be! So I assume DWORDs as the smallest entities that get passed to subroutines. (I use word-size and even byte-size variables in my own code, but never on the stack.)

* As in ASS-U-ME ...
Title: Re: Problem: ChildWindowFromPoint() prototype
Post by: hutch-- on July 04, 2015, 03:15:18 PM
The link data is correct here and it has to do with a quirk of C compilers, a POINT structure is generally passed as 2 x DWORD rather than a single DWORD address of a POINT structure. It is passed BY VALUE rather than by REFERENCE and it is a shortfall in the documentation that this is not explained. Part of the problem with an attitude of "NoCforMe" is that Windows API functions ARE written in C format so you will need to add some C to your CV to get how some of this stuff works.
Title: Re: Problem: ChildWindowFromPoint() prototype
Post by: TouEnMasm on August 08, 2015, 01:02:23 AM
Header:
Quote
ChildWindowFromPoint PROTO :HWND ,:POINT
POINT   STRUCT DEFALIGNMASM
   x DWORD ?
   y DWORD ?
POINT      ENDS
HWND DWORD;DWORD in 32 else 64
.data
point POINT <>
hwnd HWND 0

  invoke createwindowex ....
   mov hwnd,eax
  mov eax,"something"
   mov mov point.x,eax
   mov eax,"something else"
  mov point.y,eax
  invoke ChildWindowFromPoint,hwnd,point

works perfectly with masm