Aceguy Posted March 26, 2009 Posted March 26, 2009 (edited) anyone know of a beter more accurate way of doing this..... #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <Misc.au3> Opt("GUIOnEventMode", 1) $len=0 $Form1 = GUICreate("Form1", 24,26, 300, 300, $WS_POPUP, $WS_EX_TOPMOST) $input=GUICtrlCreateInput("",2,2,20,22) GUISetBkColor(0xaaaaaa) GUISetState(@SW_SHOW) while 1 sleep(50) $len_new=StringLen(guictrlread($input)) if $len_new<>$len Then GUICtrlSetPos($input,2,2,int(20+($len_new*4.5)),22) $pos = ControlGetPos("Form1","",$input) WinMove("Form1","",300,300,$pos[2]+2,26) $len=$len_new EndIf WEnd Edited March 26, 2009 by Aceguy [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock
youknowwho4eva Posted March 26, 2009 Posted March 26, 2009 (edited) I came up with this, but it only works well after about 6 characters. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <Misc.au3> Opt("GUIOnEventMode", 1) $len=0 $Form1 = GUICreate("Form1", 24,26, 300, 300, $WS_POPUP, $WS_EX_TOPMOST) $input=GUICtrlCreateInput("",2,2,20,22) GUISetBkColor(0xaaaaaa) GUISetState(@SW_SHOW) while 1 sleep(50) $len_new=StringLen(guictrlread($input)) if $len_new<>$len Then $width = Int(20+($len_new*4.5)) GUICtrlSetPos($input,2,2,$width,22) $pos = ControlGetPos("Form1","",$input) WinMove("Form1","",300,300,$width + 4,26) $len=$len_new EndIf WEnd Edit: also if you backspace, it doesn't move the window down a size... Idono Edited March 26, 2009 by youknowwho4eva Giggity
Moderators Melba23 Posted March 26, 2009 Moderators Posted March 26, 2009 Aceguy, Try this version:expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Misc.au3> #include <SendMessage.au3> #include <WinAPI.au3> Opt("GUIOnEventMode", 1) Opt("OnExitFunc", "_On_Exit") $len = 0 $Form1 = GUICreate("Form1", 24, 26, 300, 300, $WS_POPUP, $WS_EX_TOPMOST) $input = GUICtrlCreateInput("", 2, 2, 20, 22) GUISetBkColor(0xaaaaaa) GUISetState(@SW_SHOW) ; Create label to hold line as it grows $hText_Label = GUICtrlCreateLabel("", 0, -50) ; Initialise Point32 method $hWnd = ControlGetHandle($Form1, "", $hText_Label) $hFont = _SendMessage($hWnd, $WM_GETFONT) $hDC = _WinAPI_GetDC($hWnd) $oFont = _WinAPI_SelectObject($hDC, $hFont) While 1 $len_new = _String_Len(GUICtrlRead($input)) ;ConsoleWrite($len_new & @CRLF) If $len_new <> $len Then WinMove("Form1", "", 300, 300, $len_new + 24, 26) GUICtrlSetPos($input, 2, 2, $len_new + 20, 22) $len = $len_new EndIf WEnd Func _String_Len($sString) GUICtrlSetData($hText_Label, $sString) $tSize = _WinAPI_GetTextExtentPoint32($hDC, $sString) Return DllStructGetData($tSize, "X") EndFunc Func _On_Exit() _WinAPI_ReleaseDC($hWnd, $hDC) EndFunc 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
Aceguy Posted March 26, 2009 Author Posted March 26, 2009 TY guys........ SUPERB... just what im after. [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock
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