cherdeg Posted May 13, 2008 Posted May 13, 2008 Hello Alltogether, maybe I'm too dumb , but I can't get it cracking...never the less it's probably very simple: I want to align the text of a label centered in a popup-window (no controls, no title bar, etc.). The vertical position will be set manually, but the horizontal position should be centered, because the lenght of the text will vary. CODE#include <GUIConstants.au3> $InfoValue = "Primary DNS setzen..." GUICreate("", 350, 200, -1, -1, $WS_Popup, "", "") GUICtrlCreateLabel($InfoValue, "", "", "", "", $SS_Center, "") GUISetState(@SW_SHOW) Sleep(2000) Thank you very much for a working code example, Best Regards, Chris
monoceres Posted May 13, 2008 Posted May 13, 2008 You were close: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> $InfoValue = "Primary DNS setzen..." GUICreate("", 350, 200, -1, -1, $WS_Popup, "", "") GUICtrlCreateLabel($InfoValue, 0, 25, 350, -1, $SS_Center, "") GUISetState(@SW_SHOW) Sleep(2000) If you need to use the default settings use -1 instead of "" because that is zero so you actually told it to be zero pixels long Broken link? PM me and I'll send you the file!
smashly Posted May 13, 2008 Posted May 13, 2008 (edited) Hi, You can use the wrong Style on the label and have the text in the Horizontal & Vertical center of the Label as well. But doing so will kill the wordwrap#include <GUIConstants.au3> Global $InfoValue = "Using BitOr($SS_CENTER,$BS_CENTER) styles on a label :-)" Global $Timer = 1100, $i $hGui = GUICreate("", 350, 200, -1, -1, $WS_Popup) $Label = GUICtrlCreateLabel($InfoValue, 0, 0, 350, 200, BitOr($SS_CENTER,$BS_CENTER)) GUISetState(@SW_SHOW, $hGui) AdlibEnable("RotateInfo", $Timer) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func RotateInfo() AdlibDisable() Local $SSI = StringSplit($InfoValue, " "), $Data If $i > $SSI[0] Or $i < 1 Then $i = 1 $Timer = 1100 $Data = $InfoValue Else $Timer = 700 $Data = $SSI[$i] $i += 1 EndIf GUICtrlSetData($Label, $Data) AdlibEnable("RotateInfo", $Timer) EndFunc Cheers Edited May 13, 2008 by smashly
cherdeg Posted May 13, 2008 Author Posted May 13, 2008 Whoa!!! Great, guys!!! Thank you very much - I knew I was dumb...
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