Jump to content

centering text in a picture


Recommended Posts

  • Moderators

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.

Link to comment
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.

Link to comment
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

Link to comment
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)
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...