Jump to content

_WinAPI_GetObject


Recommended Posts

Using _WinAPI_GetObject() from WinAPI.au3 always reports an error for me when I'm trying, for example, to retrieve the logical font structure for a font handle. Snippet:

Local $tFONT = DllStructCreate($tagLOGFONT)
    Local $hDC = _WinAPI_GetDC($hGUI)
    Local $hFont = _SendMessage($hGUI, $WM_GETFONT, 0)
    _WinAPI_GetObject($hFont, DllStructGetSize($tFONT), DllStructGetPtr($tFONT))
    DllStructSetData($tFONT, "FaceName", "Courier New")

This gives me a message box error on the _WinAPI_GetObject() call because the return value is non-zero. However, the return value as I understand it is the number of bytes copied in to the structure so this check is a little overzealous. Or have I missed something?

WBD

Link to comment
Share on other sites

Func _WinAPI_GetObject($hObject, $iSize, $pObject)
    Local $aResult

    $aResult = DllCall("GDI32.dll", "int", "GetObject", "int", $hObject, "int", $iSize, "ptr", $pObject)
    _WinAPI_Check("_WinAPI_GetObject", ($aResult[0] = 0), 0, True)
    Return $aResult[0]
EndFunc   ;==>_WinAPI_GetObject

So it raises an error if $aResult[0] = 0 which is never true. When I do the DllCall myself and basically ignore the return value then everything works as I would like it to. Is this a bug in _WinAPI_GetObject()?

WBD

Link to comment
Share on other sites

Doh! Thanks for pointing out my stupid mistake :D

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...