ZetupEXE Posted August 11, 2010 Share Posted August 11, 2010 Hi, just a short question: Is it possible to get the GuiCtrlCreateLabel Font Attributes? i.e.: I have a GuiCtrlCreateLabel that i have formated with GuiCtrlSetFont. My question is, is it possible to "readout" the give Fontsize, and Weight later in a script? thx for you help cu. Zetup-EXE Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted August 11, 2010 Share Posted August 11, 2010 Not that I know of, and frankly I don't see the point. If you're setting it with GUICtrlSetFont() then you already know the size and weight. Because you set it. Just store it in an array and use when needed. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Yashied Posted August 11, 2010 Share Posted August 11, 2010 (edited) Something like this? expandcollapse popup#Include <Array.au3> #Include <FontConstants.au3> #Include <WinAPI.au3> #Include <WindowsConstants.au3> GUICreate('MyGUI', 300, 200) $Label = GUICtrlCreateLabel('Simple Text', 20, 40, 100, 22) GUICtrlSetFont(-1, 12, 700, 2 + 4, 'Tahoma') GUISetState(@SW_SHOW) $aFont = GUICtrlGetFont($Label) _ArrayDisplay($aFont) Do Until GUIGetMsg() = -3 #cs [0] - Size [1] - Weight [2] - Attribute [3] - Name [4] - Quality #ce Func GUICtrlGetFont($CtrlID) Local $hWnd = GUICtrlGetHandle($CtrlID) If Not $hWnd Then Return 0 EndIf Local $Ret, $hDC, $hFont, $tFont Local $aFont = 0 $hDC = _WinAPI_GetDC($hWnd) $hFont = _SendMessage($hWnd, $WM_GETFONT) $tFont = DllStructCreate($tagLOGFONT) $Ret = DllCall('gdi32.dll', 'int', 'GetObjectW', 'ptr', $hFont, 'int', DllStructGetSize($tFont), 'ptr', DllStructGetPtr($tFont)) If (Not @error) And ($Ret[0]) Then Dim $aFont[5] = [0] $aFont[0] = -Round(DllStructGetData($tFont, 'Height') / _WinAPI_GetDeviceCaps($hDC, $LOGPIXELSY) * 72, 1) $aFont[1] = DllStructGetData($tFont, 'Weight') $aFont[2] = BitOR(2 * (DllStructGetData($tFont, 'Italic') <> 0), 4 * (DllStructGetData($tFont, 'Underline') <> 0), 8 * (DllStructGetData($tFont, 'Strikeout') <> 0)) $aFont[3] = DllStructGetData($tFont, 'FaceName') $aFont[4] = DllStructGetData($tFont, 'Quality') EndIf _WinAPI_ReleaseDC($hWnd, $hDC) Return $aFont EndFunc ;==>GUICtrlGetFont Edited August 11, 2010 by Yashied VAN0, pixelsearch and Professor_Bernd 3 My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
ZetupEXE Posted August 11, 2010 Author Share Posted August 11, 2010 @Yashied: Yes! - That's it, but i am to dump to get this into my code. so could you assist a little bit? the following code is just my training place (my personal proof of possibility). if you hover over the "link" BIG HOVER you'll see, why i need to have the fontsize and weight. with notepad++ (well i use scite for programming) in line 75 (GUICtrlSetFont($lastControlID, 8.5)) i need to have the fontsize and weight from the control that the mouse was coming from. my problem here is, that on initialstart the gui crashes (if i inserted your function and call it at (not shown here!) line 74) because the backpic is also a control. the totally project aim is to build something like the windows 7 systemcontrolcenter with links in different sizes. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #Include <Misc.au3> $gui = GUICreate ("TestGUI", 384, 384, -1, -1, -1, $WS_EX_TOPMOST) GUISetBkColor (0xABCEDF, $gui) $bckpicState = GUICtrlCreatePic (@ScriptDir & "\LogonScreenPE30.bmp", 0, 0, 384, 384) GUICtrlSetState ($bckpicState, $GUI_DISABLE) $test0 = _Hyperlinklabel("Hallo Welt", 10, 11, 256, 16, 8.5, 400) GUICtrlSetBkColor ($test0, 0xAAAAAA) $test1 = _Hyperlinklabel("Hallo Ihr", 10, 27, 256, 16, 8.5, 400) GUICtrlSetBkColor ($test1, 0xCCCCCC) $test2 = _Hyperlinklabel("Hallo DuDA", 10, 43, 256, 16, 8.5, 400) GUICtrlSetBkColor ($test2, 0xEEEEEE) $test3 = _Hyperlinklabel("BIG HOVER", 10, 128, 256, 22, 12, 800) GUICtrlSetBkColor ($test2, 0xEEEEEE) GUISetState(@SW_SHOW) $linkact=False $lastControlID="None" While 1 $msg = GUIGetMsg() $aCursorInfo = GUIGetCursorInfo() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $test0 MsgBox (0, "", "0") Case $msg = $test1 MsgBox (0, "", "1") Case $msg = $test2 MsgBox (0, "", "2") Case $msg = _IsPressed("0D") EndSelect If Not @error Then ToolTip ($aCursorInfo[4] & " " & $lastControlID & @CR & GUICtrlRead ($lastControlID)) Select Case $aCursorInfo[4] = $test0 _Hyperlinkactive($test0, 12, 800) Case $aCursorInfo[4] = $test1 _Hyperlinkactive($test1, 9, 800) Case $aCursorInfo[4] = $test2 _Hyperlinkactive($test2, 9, 800) Case $aCursorInfo[4] = $test3 _Hyperlinkactive($test3, 12, 400) Case $aCursorInfo[4] = $bckpicState _Hyperlinkactive("NoHoverSmall", 8.5, 400) EndSelect EndIf WEnd Func _Hyperlinklabel($htext, $hposX, $hposY, $hwidth, $hhight, $hsize, $hweight) $label = GUICtrlCreateLabel ($htext, $hposX, $hposY, $hwidth, $hhight, $SS_CENTER) GUICtrlSetFont($label, $hsize, $hweight, 0) Return $label EndFunc Func _Hyperlinkactive($controlID, $hfontsize, $hfontwight) Select Case $linkact=False GUICtrlSetFont($controlID, $hfontsize, $hfontwight, 4) GUICtrlSetCursor($controlID, 0) $linkact=True Case $controlID <> $lastControlID GUICtrlSetFont($lastControlID, 8.5) $linkact=False $lastControlID = $controlID Case $controlID = "NoHoverSmall" GUICtrlSetFont($lastControlID, $hfontsize, $hfontwight) $linkact=False $lastControlID = $controlID EndSelect EndFunc thx. for you help. pic is in zip archive! cu. Zetup-EXELogonScreenPE30.7z 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