jennico Posted November 26, 2008 Share Posted November 26, 2008 i would like to have the label text vertically centered. does anyone know how to do this ? $gui=GUICreate("") $label=GUICtrlCreateLabel("this is a label",10,10,100,25) GUICtrlSetBkColor(-1,0xFFFFFF) GUISetState() Do $msg=GUIGetMsg() Until $msg=-3 thx j. Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96 Link to comment Share on other sites More sharing options...
Malkey Posted November 26, 2008 Share Posted November 26, 2008 i would like to have the label text vertically centered. does anyone know how to do this ? $gui=GUICreate("") $label=GUICtrlCreateLabel("this is a label",10,10,100,25) GUICtrlSetBkColor(-1,0xFFFFFF) GUISetState() Do $msg=GUIGetMsg() Until $msg=-3oÝ÷ ÚØqú®¢×+0¢¹,jëh×6Global Const $SS_CENTER = 1 ;From StaticConstants.au3 $gui = GUICreate("") $label = GUICtrlCreateLabel("this is a label", 10, 10, 22, 53, $SS_CENTER) GUICtrlSetBkColor(-1, 0xFFFFFF) GUISetState() Do $msg = GUIGetMsg() Until $msg = -3 Link to comment Share on other sites More sharing options...
rasim Posted November 26, 2008 Share Posted November 26, 2008 jennicoNot elegant, but works:#include <StaticConstants.au3> $gui = GUICreate("Test", 300, 240) $label = GUICtrlCreateLabel(_TextVertical("this is a label"), 136, 10, 16, 200, $SS_CENTER) GUICtrlSetBkColor(-1, 0xFFFFFF) GUISetState() Do Until GUIGetMsg() = -3 Func _TextVertical($sString) Local $aChar, $retString, $i $aChar = StringSplit($sString, "") For $i = 1 To $aChar[0] $retString &= $aChar[$i] & @LF Next Return $retString EndFunc Link to comment Share on other sites More sharing options...
Malkey Posted November 26, 2008 Share Posted November 26, 2008 Adapting rasim's example, this is easier than adding spaces to the text in the label. Global Const $SS_CENTER = 1 ;From StaticConstants.au3 $gui = GUICreate("Test", 300, 240) $label = GUICtrlCreateLabel(_WordsVertical("this is a label"), 136, 10, 22, 53, $SS_CENTER) GUICtrlSetBkColor(-1, 0xFFFFFF) GUISetState() Do Until GUIGetMsg() = -3 Func _WordsVertical($sString) Local $aChar, $retString, $i $aChar = StringSplit($sString, " ") For $i = 1 To $aChar[0] $retString &= $aChar[$i] & @LF Next Return $retString EndFunc ;==>_WordsVertical Link to comment Share on other sites More sharing options...
jennico Posted November 26, 2008 Author Share Posted November 26, 2008 (edited) ay no, sorry, i used a bad formulation (?). it's not that easy, is it. (said Mick Fleetwood) i wanted to have the entire text within the label pushed downwards, so that it shows vertically centered. without a bigger label. and i need some kind of code that does it automatically for any label, font and text size, just like SS_Center does it horizontally. normally, the text is always on top of the label. but (i would say, in most cases) the user prefers the text in the vertical center. what you can do, is create a bottom label without text and with the background color, on top of it the transparent label with the text, slightly downshifted, and a third transparent label on top of the two to catch the click events. $gui=GUICreate("") $label=GUICtrlCreateLabel("this is a label",10,10,100,25) GUICtrlSetBkColor(-1,0xFFFFFF) $label1=GUICtrlCreateLabel("",120,10,100,25) GUICtrlSetBkColor(-1,0xFFFFFF) $label2=GUICtrlCreateLabel("this is a label",120,15,100,16) GUICtrlSetBkColor(-1,-2) $label3=GUICtrlCreateLabel("",120,10,100,25) GUICtrlSetBkColor(-1,-2) GUICtrlSetState(-1,2048) GUISetState() Do $msg=GUIGetMsg() if $msg=$label3 Then MsgBox(0,"","clicked") Until $msg=-3 you will agree, though working, this is kind of stupid. i need an easier way. i found the $DT_VCENTER style in _WinAPI_DrawText. would it be possible to create an empty label, get the DC of that label, create a rectangle into the label and then set the font and color and draw the text ? can anyone provide an example, if this method makes sense ? i found some examples for _WinAPI_DrawText, but they just draw on the desktop. j. Edited November 26, 2008 by jennico Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96 Link to comment Share on other sites More sharing options...
Popular Post GEOSoft Posted November 26, 2008 Popular Post Share Posted November 26, 2008 It seems to me that I used $SS_CENTERIMAGE to get vertical centering on a label control. Xandy, Burgaud, Kloud and 2 others 3 2 George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
jennico Posted November 26, 2008 Author Share Posted November 26, 2008 GEOSoft: i keep on loving you forever !!!!!!!!!!!! kisseskisseskisses j. Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96 Link to comment Share on other sites More sharing options...
GEOSoft Posted November 26, 2008 Share Posted November 26, 2008 (edited) GEOSoft: i keep on loving you forever !!!!!!!!!!!! kisseskisseskisses j.Careful where you go with that, boy!!Guessing that I remembered correctly.Edit: If you want to test control styles without actually typing the code, try this handy little tool. I don't use it nearly as often as I should because I have to keep searching my system for it. One of these days I'll get around to creating a shortcut in my Developer Tools Menu.MS Control SpyI'm thinking that someday I'll get around to writing the same thing in AutoIt but that day is a long way off. Edited November 26, 2008 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
jennico Posted November 26, 2008 Author Share Posted November 26, 2008 this is a nice tool, thank you. should be included in autoit package. once again i am very pleased with msdn and all the help microsoft offers to devs. j. Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96 Link to comment Share on other sites More sharing options...
GEOSoft Posted November 26, 2008 Share Posted November 26, 2008 this is a nice tool, thank you. should be included in autoit package. once again i am very pleased with msdn and all the help microsoft offers to devs.j.I think it would be better to create an AutoIt specific version before it was made part of the package. As a matter of fact it might be better off as a part of Scite. Maybe we could nudge Jos a bit and save me the trouble of writing it.BTW I just added my shortcut so I can locate it quickly. You don't really need the V5 file either. For AutoIt, it's the V6 file that you will be using. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Valuater Posted November 26, 2008 Share Posted November 26, 2008 (edited) It seems to me that I used $SS_CENTERIMAGE to get vertical centering on a label control.Me too, all the time... .... and I usually use "$SS_CENTER + $SS_CENTERIMAGE" abd that's not correctBut it works, I don't know why... 8) Edited November 26, 2008 by Valuater Link to comment Share on other sites More sharing options...
GEOSoft Posted November 26, 2008 Share Posted November 26, 2008 Me too, all the time... .... and I usually use "$SS_CENTER + $SS_CENTERIMAGE" abd that's not correctBut it works, I don't know why... 8)Actually when you look it up on MSDN (or use that tool I linked to) it is correct, although I think I BitOr'd them (could be wrong).$SS_Center is horizontal and (not mentioned in the help file) $SS_CENTERIMAGE will add vertical centering.I'm not suggesting that it be added to the help file either since that particular style is already very crowded on the style table and I wouldn't like to add more confusion. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Valuater Posted November 26, 2008 Share Posted November 26, 2008 To BitOr'd them is correct, the "+" I used is not, however it is the only way it would work 8) Link to comment Share on other sites More sharing options...
martin Posted November 26, 2008 Share Posted November 26, 2008 To BitOr'd them is correct, the "+" I used is not, however it is the only way it would work8)That sounds familiar. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
jennico Posted November 26, 2008 Author Share Posted November 26, 2008 512 + 1 = 513 works, too. BitOr(0x200, 0x1) is 0x201 and that is 513, too. but not always, it seems. Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96 Link to comment Share on other sites More sharing options...
GEOSoft Posted November 26, 2008 Share Posted November 26, 2008 (edited) Well just to make life simpler I've started working on an AutoIt version of that MS Tool but don't hold your breath expecting it to be finished in short order. I'm pretty sure that I will be sticking to BitOr() but one can never be sure of these things. EDIT: Of course this is perhaps letting Jos of the hook. Not sure why I would do that though. Edited November 26, 2008 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Malkey Posted November 27, 2008 Share Posted November 27, 2008 512 + 1 = 513 works, too. BitOr(0x200, 0x1) is 0x201 and that is 513, too. but not always, it seems.Using Siao's Bitwise Operations Visualizer at, http://www.autoitscript.com/forum/index.ph...st&p=466668one can see what is happening at bit level for better understanding.An example copied from above tool.Bitor(513, 1) = 51300000000000000000000001000000001 0x00000201OR00000000000000000000000000000001 0x00000001=00000000000000000000001000000001 0x00000201 Link to comment Share on other sites More sharing options...
jennico Posted November 27, 2008 Author Share Posted November 27, 2008 another nice tool, comes in my autoit directory. but the good old calc.exe does it alright when you use its scientific panel. Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96 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