The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: peaslee on November 10, 2010, 06:33:58 PM

Title: TYPE problem
Post by: peaslee on November 10, 2010, 06:33:58 PM
msdn shows one of the parameters of the GetTextExtentPoint32 function as LPSIZE. When I try it, I get an "undefined symbol" error. What is the best way to handle this?

Thanks,
Title: Re: TYPE problem
Post by: jj2007 on November 10, 2010, 06:44:48 PM
Try interpreting lpSize as a pointer to a SIZE structure.
Title: Re: TYPE problem
Post by: dedndave on November 10, 2010, 07:27:56 PM
yes - lpSize is not defined - you have to create the structure, and pass the pointer
Title: Re: TYPE problem
Post by: MichaelW on November 10, 2010, 11:25:51 PM

typedef struct tagSIZE
{
    LONG        cx;
    LONG        cy;
} SIZE, *PSIZE, *LPSIZE;


The first problem with this definition is that SIZE is a MASM reserved word, so the structure was renamed to SIZEL. The second problem is that one of the members conflicts with the reserved word CX, so the members were renamed to simply x and y.


SIZEL STRUCT
  x  DWORD      ?
  y  DWORD      ?
SIZEL ENDS


And I assume that there is no LPSIZE or LPSIZEL defined because it's not actually needed, and as far as I know, given the limited type checking that MASM performs, it would provide no benefit.


;=========================================================================
    include \masm32\include\masm32rt.inc
;=========================================================================
    .data
        sz    SIZEL <>
        str1  db    "my other brother darryl",0
    .code
;=========================================================================
start:
;=========================================================================

    invoke GetDC, NULL
    invoke GetTextExtentPoint32, eax, ADDR str1, SIZEOF str1, ADDR sz

    print str$(sz.x),9
    print str$(sz.y),13,10,13,10

    inkey "Press any key to exit..."
    exit

;=========================================================================
end start

Title: Re: TYPE problem
Post by: peaslee on November 11, 2010, 09:39:02 PM
That does it.

Thanks.