60aside Posted October 22, 2009 Share Posted October 22, 2009 Hi, I've been struggling with this for a while now, I think I'm missing something simple. The form below will be maximised and will run on machines with different screen resolutions. I need the text "Please Wait . . ." to be centred vertically and horizontally in the form. At present, when maximised it shifts over to the left. Please can you advise how to fix this? #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 625, 443, 192, 124, BitOR($WS_MAXIMIZE,$WS_POPUP)) GUISetFont(18, 400, 0, "Arial") GUISetBkColor(0xFFFFFF) $Label1 = GUICtrlCreateLabel("Please Wait . . .", 225, 206, 174, 31) GUICtrlSetColor(-1, 0x0000FF) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
BigDod Posted October 22, 2009 Share Posted October 22, 2009 #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 625, 443, 192, 124, BitOR($WS_MAXIMIZE,$WS_POPUP)) GUISetFont(18, 400, 0, "Arial") GUISetBkColor(0xFFFFFF) $Label1 = GUICtrlCreateLabel("Please Wait . . .", @DesktopWidth/2-87, @DesktopHeight/2-16, 174, 31) GUICtrlSetColor(-1, 0x0000FF) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
60aside Posted October 22, 2009 Author Share Posted October 22, 2009 That's great thanks a lot. Link to comment Share on other sites More sharing options...
Zedna Posted October 22, 2009 Share Posted October 22, 2009 Another way #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 300,200, -1, -1, BitOr($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_MAXIMIZEBOX )) GUISetFont(18, 400, 0, "Arial") GUISetBkColor(0xFFFFFF) $Label1 = GUICtrlCreateLabel("Please Wait . . .", 0, 100, 300, 31, BitOr($GUI_SS_DEFAULT_LABEL, $SS_CENTER)) GUICtrlSetResizing(-1,$GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKHEIGHT) GUICtrlSetColor(-1, 0x0000FF) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Malkey Posted October 23, 2009 Share Posted October 23, 2009 Nice try Zedna, but not quite right. $Label1 = GUICtrlCreateLabel("Please Wait . . .", (300-174)/2, (200-25)/2, 174, 25, BitOr($GUI_SS_DEFAULT_LABEL, $SS_CENTER)) [GUI size 300x200] (300-174)/2, (200-31)/2 - centers the center of the label at the center of the initial GUI, window horizontally and vertically, and, $SS_CENTER - centers the text within the label's rectangular area horizontally. GUICtrlSetResizing(-1, $GUI_DOCKHCENTER+ $GUI_DOCKVCENTER) - keeps the label at the center of the re-sizing window up to or down from maximium size horizontally and vertically. #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 300, 200, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_MAXIMIZEBOX)) GUISetFont(18, 400, 0, "Arial") GUISetBkColor(0xFFFFFF) $Label1 = GUICtrlCreateLabel("Please Wait . . .", (300 - 174) / 2, (200 - 25) / 2, 174, 25, BitOR($GUI_SS_DEFAULT_LABEL, $SS_CENTER)) GUICtrlSetResizing(-1, $GUI_DOCKHCENTER + $GUI_DOCKVCENTER + $GUI_DOCKSIZE) GUICtrlSetColor(-1, 0x0000FF) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
Zedna Posted October 23, 2009 Share Posted October 23, 2009 Nice try Zedna, but not quite right.Did you try my script?!? It's right. Label has the same width as your GUI even if you resize your GUI.So centered text inside label is sufficient in this case. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Malkey Posted October 23, 2009 Share Posted October 23, 2009 Did you try my script?!? It's right. Label has the same width as your GUI even if you resize your GUI.So centered text inside label is sufficient in this case.Either you did not understand what the 60aside was asking. ...I need the text "Please Wait . . ." to be centred vertically and horizontally in the form.At present, when maximised it shifts over to the left....Or, my operating system, xp, does not display the same as yours'.In your script the text appears to gravitate to the top when re-sizing the window to maximum - losing the vertical centredness, which is wrong. 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