News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Problem: ChildWindowFromPoint() prototype

Started by NoCforMe, June 08, 2015, 03:48:07 PM

Previous topic - Next topic

NoCforMe

The prototype for ChildWindowFromPoint() in windows.inc seems to be wrong. It calls for 3 parameters, while MSDN says there are only 2. 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 ...
32-bit code and Windows 7 foreva!

hutch--

Its a quirk of C notation, the linker is telling you the truth.

NoCforMe

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.
32-bit code and Windows 7 foreva!

NoCforMe

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 ...
32-bit code and Windows 7 foreva!

dedndave

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

NoCforMe

Quote from: dedndave on June 08, 2015, 07:14:31 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 ...
32-bit code and Windows 7 foreva!

hutch--

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.

TouEnMasm

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




Fa is a musical note to play with CL