WideBoyDixon Posted April 9, 2009 Share Posted April 9, 2009 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 [center]Wide by name, Wide by nature and Wide by girth[u]Scripts[/u]{Hot Folders} {Screen Calipers} {Screen Crosshairs} {Cross-Process Subclassing} {GDI+ Clock} {ASCII Art Signatures}{Another GDI+ Clock} {Desktop Goldfish} {Game of Life} {3D Pie Chart} {Stock Tracker}[u]UDFs[/u]{_FileReplaceText} {_ArrayCompare} {_ToBase}~ My Scripts On Google Code ~[/center] Link to comment Share on other sites More sharing options...
Authenticity Posted April 9, 2009 Share Posted April 9, 2009 I think _WinAPI_GetObject gives an error if the return value is 0. Try to call GetObject yourself to see if the return is not zero. Link to comment Share on other sites More sharing options...
WideBoyDixon Posted April 9, 2009 Author Share Posted April 9, 2009 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 [center]Wide by name, Wide by nature and Wide by girth[u]Scripts[/u]{Hot Folders} {Screen Calipers} {Screen Crosshairs} {Cross-Process Subclassing} {GDI+ Clock} {ASCII Art Signatures}{Another GDI+ Clock} {Desktop Goldfish} {Game of Life} {3D Pie Chart} {Stock Tracker}[u]UDFs[/u]{_FileReplaceText} {_ArrayCompare} {_ToBase}~ My Scripts On Google Code ~[/center] Link to comment Share on other sites More sharing options...
Authenticity Posted April 9, 2009 Share Posted April 9, 2009 Did you check if $hFont is not null? According to MSDN WM_GETFONT The return value is the handle of the font used by the control, or NULL if the control is using the system font. Link to comment Share on other sites More sharing options...
WideBoyDixon Posted April 9, 2009 Author Share Posted April 9, 2009 Doh! Thanks for pointing out my stupid mistake [center]Wide by name, Wide by nature and Wide by girth[u]Scripts[/u]{Hot Folders} {Screen Calipers} {Screen Crosshairs} {Cross-Process Subclassing} {GDI+ Clock} {ASCII Art Signatures}{Another GDI+ Clock} {Desktop Goldfish} {Game of Life} {3D Pie Chart} {Stock Tracker}[u]UDFs[/u]{_FileReplaceText} {_ArrayCompare} {_ToBase}~ My Scripts On Google Code ~[/center] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now