Sign in to follow this  
Followers 0
sharrakor

Help putting a variable into a gui label, and $SS_CENTER

13 posts in this topic

I was trying to pass a variable into a gui label, but i couldn't figure out how to get it to work. I tried:

guictrlcreatelabel("You've completed "$variable"runs.",50,50,100,50,$ss_center)

This code doesn't work though, and apparently I'm using the $ss_center command incorrectly, because it is basing the location of the label on my X corrdinate. What would be the best approach to making a centered statement in a gui window?

Share this post


Link to post
Share on other sites



To mix variables and text you have to concatenate the text with an ampersand

"You've completed " & $variable & "runs."

If you want the label to be centered on both the horizontal AND vertical plane use

BitOR($SS_CENTER, $SS_CENTERIMAGE)

Share this post


Link to post
Share on other sites

Thanks a lot. Making my first GUI was a little harder than it had to be apparently!

Share this post


Link to post
Share on other sites

Ok, that didn't work exactly as I expected. What I mean is, if I have:

guicreate("About",300,300)
guisetstate(@sw_show)
guictrlcreatelabel("You've completed " & $variable & "runs.",100,25,100,25,$SS_CENTER)

I want my label to be perfectly centered, regardless of how many digits $variable is. I only want to specify the Y coordinate; the script should decide what the starting X coordinate is. Is there any way to do this?

Share this post


Link to post
Share on other sites

Thanks to both of you. Nice program, and also nice to know how to do it manually.

Share this post


Link to post
Share on other sites

You would do that like this:

guicreate("About",300,300)
guisetstate(@sw_show)
guictrlcreatelabel("You've completed " & $variable & "runs.",0,25,300,25,$SS_CENTER)
Ever since upgrading to 3.3.0 it tells me that the $SS_CENTER has been used before being declared and stops the script. It worked fine before. Anyone no what's the deal?

EndFuncAutoIt is the shiznit. I love it.

Share this post


Link to post
Share on other sites

Ever since upgrading to 3.3.0 it tells me that the $SS_CENTER has been used before being declared and stops the script. It worked fine before. Anyone no what's the deal?

$SS_CENTER is now defined in WindowsConstants.au3:

#include <WindowsConstants.au3>

Share this post


Link to post
Share on other sites

$SS_CENTER is now defined in WindowsConstants.au3:

#include <WindowsConstants.au3>

Thanks but its still not working. I added the include but continue to have the errors.

WARNING: $ES_CENTER: possibly used before declaration.

WARNING: $BS_FLAT: possibly used before declaration.

WARNING: $CBS_DROPDOWNLIST: possibly used before declaration.

Anything else I can do?


EndFuncAutoIt is the shiznit. I love it.

Share this post


Link to post
Share on other sites

Endfunc, try

#Include <GuiEdit.au3>

Share this post


Link to post
Share on other sites

Endfunc, try

#Include <GuiEdit.au3>
Well it decreased my warning to 4 but still have some.

WARNING: $SS_CENTER: possibly used before declaration.

These are my includes.

#include <GUIConstants.au3>

#include <constants.au3>

#include "File.au3"

#include "GuiTab.au3"

#include "INet.au3"

#include "IE.au3"

#include "String.au3"

#Include <Array.au3>

#include <CompInfo.au3>

#include <WindowsConstants.au3>

#Include <GuiEdit.au3>


EndFuncAutoIt is the shiznit. I love it.

Share this post


Link to post
Share on other sites

Well it decreased my warning to 4 but still have some.

WARNING: $SS_CENTER: possibly used before declaration.

These are my includes.

#include <GUIConstants.au3>

#include <constants.au3>

#include "File.au3"

#include "GuiTab.au3"

#include "INet.au3"

#include "IE.au3"

#include "String.au3"

#Include <Array.au3>

#include <CompInfo.au3>

#include <WindowsConstants.au3>

#Include <GuiEdit.au3>

Wow after reading this,

http://www.autoitscript.com/forum/index.php?showtopic=88948

The includes are all changed now. Completely hosed alot of things if you want to use that version. Now I have to try and figure out what needs to be replaced.

Fixed it with this

#include <StaticConstants.au3>

Must be new.


EndFuncAutoIt is the shiznit. I love it.

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