Jump to content

GUICtrlCreateLabel alignment


erebus
 Share

Recommended Posts

Hello all,

I am trying to find a workaround on a label's alignment but with no luck.

Let's say we have a single line GUICtrlCreateLabel($status) and we want to locate it in the middle of our GUI's width (or even height). If we know the $status length we can do this by hand; however if we don't use a fixed width font when we update $status there is no way to know the exact label's width (in pixels and NOT in characters) so as to locate it appropriately in the GUI.

Any suggestions?

Link to comment
Share on other sites

Hello all,

I am trying to find a workaround on a label's alignment but with no luck.

Let's say we have a single line GUICtrlCreateLabel($status) and we want to locate it in the middle of our GUI's width (or even height). If we know the $status length we can do this by hand; however if we don't use a fixed width font when we update $status there is no way to know the exact label's width (in pixels and NOT in characters) so as to locate it appropriately in the GUI.

Any suggestions?

I do not know if this is what you require.

#include <GUIConstants.au3>
;Generated with Form Designer preview
$Text = InputBox("Input", "What do you wish to type")
$Form1 = GUICreate("AForm1", 386, 142, 192, 113)
$Label1 = GUICtrlCreateLabel( $Text, 0, 0, 382, 137, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
    ;;;;;;;
    EndSelect
WEnd
Exit


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

Exactly, thank you very much.

However (and while I am not familiar with the use of BitOR) can you please give me another example?

Let's say that I have a GUI of 500 pixels width and 400 height and I want to put my label at 100 pixels height and center it between 200 and 300 pixels width only.

Since I don't exactly understand the use of BitOR I have no idea of how to alter that line of your code. :/

Thank you very much.

Link to comment
Share on other sites

Exactly, thank you very much.

However (and while I am not familiar with the use of BitOR) can you please give me another example?

Let's say that I have a GUI of 500 pixels width and 400 height and I want to put my label at 100 pixels height and center it between 200 and 300 pixels width only.

Since I don't exactly understand the use of BitOR I have no idea of how to alter that line of your code. :/

Thank you very much.

To be honest with you I do not understand BitOR either I just played around with KODA. It is a brilliant tool that you can download http://www.autoitscript.com/fileman/users/lookfar/index.html


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

To be honest with you I do not understand BitOR either I just played around with KODA. It is a brilliant tool that you can download http://www.autoitscript.com/fileman/users/lookfar/index.html

BitOr is a bitwise OR comparison....

example:

A = 1000001

B = 1000010

For each bit, if there is a 1 in that position on the A or in the same position for a B, or both, a 1 is returned, otherwise a zero... so a bitwise or of those two would yield:

1000011 or C

Link to comment
Share on other sites

You gave the perfect example, thank you very much, I really understood how it works now.

However I haven't yet understood where $SS_CENTER and $SS_CENTERIMAGE depend on (in GUIConstants.au3) and how exactly to use them.

Can anybody give us a good example/explanation of how they technically work?

Link to comment
Share on other sites

You gave the perfect example, thank you very much, I really understood how it works now.

However I haven't yet understood where $SS_CENTER and $SS_CENTERIMAGE depend on (in GUIConstants.au3) and how exactly to use them.

Can anybody give us a good example/explanation of how they technically work?

how they work, is the GUIConstants assigns names to the binary values. when you do a bitor() on those constants, you're actually doing a bitwise or comparison on the values they represent, and that is passed to the operating system... although i think bitand() would be the way to combine the styles... ignore that last line, bitand would obviously not combine the values correctly, it was late and i was tired... the reason it wouldn't is because a bitand would only put 1's in the positions that both have a 1... or to use the same example as earlier...

A = 1000001

B = 1000010

a BitAnd() would return 1000000 or @ which would not be a combination of the two by any means...

Edited by cameronsdad
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...