Moderators Melba23 Posted December 19, 2008 Moderators Posted December 19, 2008 Hi, I am trying to get my head around fonts - not an easy task as I am rapidly finding out! At this moment I am attempting to identify the font used in a control - something which Au3 Window Info does not give me - perhaps for a very good reason! I have found that I can get the handle to the font in a control by using the following:$hWnd = ControlGetHandle($hGui, "", $hControl) $hFont = _SendMessage($hWnd, $WM_GETFONT, 0, 0, 5) This returns a nice array: [0] = 185211881 [1] = 0x000508F4 [2] = 49 [3] = 0 [4] = 0 which is all very well, but does not let me identify the font in question. I have looked through MSDN and Googled furiously and there does not appear to be function to get the font family/size data from this handle, although I have found a number of quotes such as: "HFONT, a handle to a Logical Font in memory. The data held by this handle can be retrieved into a LOGFONT structure" So to my question: How can you get the LOGFONT from the handle in AutoIt? From my studies, I believe the LOGFONT structure should read: $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]") derived from: typedef struct tagLOGFONT { LONG lfHeight; LONG lfWidth; LONG lfEscapement; LONG lfOrientation; LONG lfWeight; BYTE lfItalic; BYTE lfUnderline; BYTE lfStrikeOut; BYTE lfCharSet; BYTE lfOutPrecision; BYTE lfClipPrecision; BYTE lfQuality; BYTE lfPitchAndFamily; TCHAR lfFaceName[LF_FACESIZE]; } LOGFONT, *PLOGFONT; But how to populate it, given the handle? Grateful for any pointers (pun firmly intended!), M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
martin Posted December 19, 2008 Posted December 19, 2008 (edited) Hi, I am trying to get my head around fonts - not an easy task as I am rapidly finding out! At this moment I am attempting to identify the font used in a control - something which Au3 Window Info does not give me - perhaps for a very good reason! I have found that I can get the handle to the font in a control by using the following:$hWnd = ControlGetHandle($hGui, "", $hControl) $hFont = _SendMessage($hWnd, $WM_GETFONT, 0, 0, 5) This returns a nice array: [0] = 185211881 [1] = 0x000508F4 [2] = 49 [3] = 0 [4] = 0 which is all very well, but does not let me identify the font in question. I have looked through MSDN and Googled furiously and there does not appear to be function to get the font family/size data from this handle, although I have found a number of quotes such as: "HFONT, a handle to a Logical Font in memory. The data held by this handle can be retrieved into a LOGFONT structure" So to my question: How can you get the LOGFONT from the handle in AutoIt? From my studies, I believe the LOGFONT structure should read: $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]") derived from: typedef struct tagLOGFONT { LONG lfHeight; LONG lfWidth; LONG lfEscapement; LONG lfOrientation; LONG lfWeight; BYTE lfItalic; BYTE lfUnderline; BYTE lfStrikeOut; BYTE lfCharSet; BYTE lfOutPrecision; BYTE lfClipPrecision; BYTE lfQuality; BYTE lfPitchAndFamily; TCHAR lfFaceName[LF_FACESIZE]; } LOGFONT, *PLOGFONT; But how to populate it, given the handle? Grateful for any pointers (pun firmly intended!), M23 I don't know the answer but my guess is that you need to create a logfont structure, get the lofgont handle using $hLogFont = _SendMessage($hWnd, $WM_GETFONT, 0, 0) then get the data into the structure using $hLogFont in _WinAPI_GetObject twice, first with the first parameter as 0 to get the number of bytes needed, then use that for the second parameter the second time. So it would be something like this $hLogFont = _SendMessage($hWnd, $WM_GETFONT, 0, 0) $structLF = DllStructCreate($tagLogFont) $isize = _WinAPI_GetObject($hLogFont ,0,0) $iWritten = _WinAPI_GetObject($hLogFont ,$isize,DllStructGetptr($structLF)) then the data should be in the struct for you to read. I haven't tried it btw. Edited December 19, 2008 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Moderators Melba23 Posted December 20, 2008 Author Moderators Posted December 20, 2008 @martin, Thanks, works a treat. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
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