b8bboi Posted May 10, 2006 Share Posted May 10, 2006 I'm using GuiCtrCreateLabel to try to simulate a text input control. The reason why I don't want to use a simple input control is that I want to have a transparent background. $GUI_BKCOLOR_TRANSPARENT doesn't work on Input boxes. The label control is gonna have a fixed width. It also gets updated when user types into another (hidden) input box. The problem is I need to know when the text label is clipped so that I can trim the first few characters from the string. This way the right most characters are always visible. I hope I'm clear enough. Appreciate any help. Link to comment Share on other sites More sharing options...
blindwig Posted May 11, 2006 Share Posted May 11, 2006 I asked this question a while back.Here's the thread:http://www.autoitscript.com/forum/index.php?showtopic=13733 My UDF Threads:Pseudo-Hash: Binary Trees, Flat TablesFiles: Filter by Attribute, Tree List, Recursive Find, Recursive Folders Size, exported to XMLArrays: Nested, Pull Common Elements, Display 2dSystem: Expand Environment Strings, List Drives, List USB DrivesMisc: Multi-Layer Progress Bars, Binary FlagsStrings: Find Char(s) in String, Find String in SetOther UDF Threads I Participated:Base64 Conversions Link to comment Share on other sites More sharing options...
b8bboi Posted May 11, 2006 Author Share Posted May 11, 2006 So, did you ever figure out how to calculate the size of a text label? Link to comment Share on other sites More sharing options...
b8bboi Posted May 15, 2006 Author Share Posted May 15, 2006 so, following Valik's advice, I've tried the following but it didn't work. The GetTextExtentPoint32 function always returns a false value and doesn't return the actual size fo the label. #include <GUIConstants.au3> $myGui = GUICreate("Test Label Size") $WM_GETFONT = 0x31 $text = "ABCDEFGHIJKLMN" $hText = GUICtrlCreateLabel ($text, 10, 10, 100, 80, $SS_SIMPLE) GUICtrlSetFont(-1, 20, 600, "", "Arial Narrow") GUISetState () $MyHDC = DLLCall("user32.dll","int","GetDC","hwnd",$hText) $hFont = DllCall("user32.dll", "ptr", "SendMessage", "hwnd", $hText, "int", $WM_GETFONT, "int", 0, "int", 0) $hFont = $hFont[1] $hOld = DllCall("gdi32.dll", "Hwnd", "SelectObject", "int", $MyHDC[0], "ptr", $hFont) $res = DllStructCreate("long;long") $ret = DllCall("gdi32.dll", "int", "GetTextExtentPoint32", "int", $MyHDC[0], "str", $text, "long", StringLen($text), "ptr", DllStructGetPtr($res)) MsgBox(0, "Get Size", "Return Status="&$ret[0]&" | width="&DllStructGetData($res,0)) DLLCall("user32.dll","int","ReleaseDC","int",$MyHDC[0],"hwnd",$hText) Could anyone see why? Thanks. Link to comment Share on other sites More sharing options...
Zedna Posted April 25, 2007 Share Posted April 25, 2007 (edited) I know it's a bit late but now I need GetTextExtentPoint32 in my script so I searched forum and found also this post.Here is corrected functional version of your script (tested with AutoIt 3.2.2.0 on WINXP SP2):#include <GUIConstants.au3> $WM_GETFONT = 0x31 $text = "ABCDEF" $hGui = GUICreate("Test Label Size") $Label_1 = GUICtrlCreateLabel ($text, 10, 10, 100, 80);, $SS_SIMPLE) GUICtrlSetFont(-1, 20, 600, "", "Arial Narrow") GUISetState () $hText = ControlGetHandle($hGui, "", $Label_1) $hDC = DLLCall("user32.dll","int","GetDC","hwnd",$hText) $hDC = $hDC[0] $hFont = DllCall("user32.dll", "ptr", "SendMessage", "hwnd", $hText, "int", $WM_GETFONT, "int", 0, "int", 0) $hFont = $hFont[0] $hOld = DllCall("gdi32.dll", "Hwnd", "SelectObject", "int", $hDC, "ptr", $hFont) $struct_size = DllStructCreate("int;int") $ret = DllCall("gdi32.dll", "int", "GetTextExtentPoint32", "int", $hDC, "str", $text, "long", StringLen($text), "ptr", DllStructGetPtr($struct_size)) $hOld = DllCall("gdi32.dll", "Hwnd", "SelectObject", "int", $hDC, "ptr", $hOld) MsgBox(0, "Get Size", "Return Status=" & $ret[0] & " width=" & DllStructGetData($struct_size,1)) DLLCall("user32.dll","int","ReleaseDC","hwnd",$hText,"int",$hDC) $struct_size = 0 Edited April 25, 2007 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search 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