Author Topic: Problem: ChildWindowFromPoint() prototype  (Read 2131 times)

NoCforMe

  • Member
  • **
  • Posts: 72
Problem: ChildWindowFromPoint() prototype
« 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. 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 ...

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 4926
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Problem: ChildWindowFromPoint() prototype
« Reply #1 on: June 08, 2015, 03:58:56 PM »
Its a quirk of C notation, the linker is telling you the truth.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

NoCforMe

  • Member
  • **
  • Posts: 72
Re: Problem: ChildWindowFromPoint() prototype
« Reply #2 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.

NoCforMe

  • Member
  • **
  • Posts: 72
Re: Problem: ChildWindowFromPoint() prototype
« Reply #3 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 ...

dedndave

  • Member
  • *****
  • Posts: 8749
  • Still using Abacus 2.0
    • DednDave
Re: Problem: ChildWindowFromPoint() prototype
« Reply #4 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

NoCforMe

  • Member
  • **
  • Posts: 72
Re: Problem: ChildWindowFromPoint() prototype
« Reply #5 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 ...

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 4926
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Problem: ChildWindowFromPoint() prototype
« Reply #6 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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

ToutEnMasm

  • Member
  • *****
  • Posts: 1189
    • EditMasm
Re: Problem: ChildWindowFromPoint() prototype
« Reply #7 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




Fa is a musical note to play with CL