alt66
14 years agoNew Contributor
WinAPI32
I have been trying to call the Windows API function: GetTextExtentPoint32 But the first issue is it receives / returns a pointer (reference) to a structure (struct) containing two long (I4) variab...
Hi Luis,
I have been trying to call the Windows API function: GetTextExtentPoint32But the first issue is it receives / returns a pointer (reference) to a structure (struct) containing two long (I4) variables so when I tried this way, using Win32Api plug in, but I had no way in vbscript to declare such structure:
hwnd = UIObject.handle
dc = Win32Api.GetDC(hwnd)
ret = Win32Api.GetTextExtentPoint32(dc, UIObject.Text , Len(UIObject.Text), TextSize)
Call Win32Api.ReleaseDC(hwnd,dc)
In this case if TextSize is unidefined, it stays undefined after the call, and there is no error, if it points to a class with two variants it sends an error
You need to initialize the TextSize variable as a tagSIZE structure instance:
Set TextSize = Win32API.tagSIZE
In this case, it will correctly receive the output value, and you'll be able to get the string dimensions as TextSize.cx and TextSize.cy.