Sign in to follow this  
Followers 0
AustrianOak

centering text in a picture

8 posts in this topic

how can i center my label text on my picture? my label sizes may vary so i was wondering if there was some function for it?...

probably a long shot question

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

how can i center my label text on my picture? my label sizes may vary so i was wondering if there was some function for it?...

probably a long shot question

Look in your help file under GUI Styles ... Search for Center :)

Edit:

I am hoping that was the simple way for you above....

However, if you're trying to center your "label to the picture", then something like:

ConrolGetPos() to get the left/top/right/bottom positions, then some simple math would help you out there.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

thanks SmOke_N,

I'll go with the second way as it seems a bit easier (for me at least).

Share this post


Link to post
Share on other sites

i seem to be having a huge amount of trouble figuring out this damn math :)

i want to position my text (label) in the center of my picture so i did half the pictures width

and then i did half of the text label and im confusing myself so bad.

can somone one help me with some logic.

my goal: centering my label in on my picture.

sorry if im too vague, ill be glad to be more detailed if needed.

Share this post


Link to post
Share on other sites

For your math ...

Assuming you know the x,y pos and the width and height of the picture control and the width and height of the label ...

GUICtrlCreateLabel('This is a test label', $imageXpos+($imagewidth/2)-($Labelwidth/2), $imageYpos+($imageheight/2)-($Labelheight/2), $Labelwidth, $Labelheight)

Hopefully that makes sense, each of the values that should be assigned to the variables should be self-explanatory :)


My scripts:AppLauncherTRAY - Awesome app launcher that runs from the system tray NEW VERSION! | Run Length Encoding - VERY simple compression in pure autoit | Simple Minesweeper Game - Fun little game :)My website

Share this post


Link to post
Share on other sites

As strange it may sound my label actually started on the left side of the picture instead of center.

heres what i did:

$imageXpos = 27
$imagewidth = 78
$Labelwidth = $leng[0]
$newlabel = GUICtrlCreateLabel($datalabel, $imageXpos+($imagewidth/2)-($Labelwidth/2), 455, $leng[0], 20)

Share this post


Link to post
Share on other sites

If you set $SS_CENTER as the style for the label, then the label just need be as wide as the picture.

Lar.


f_mrcleansmalm_77ce002.jpgAutoIt has helped make me wealthy

Share this post


Link to post
Share on other sites

Thanks Larry.

Works great. :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0