Jump to content
Sign in to follow this  
kjactive

Control setting as variable trouble

Recommended Posts

kjactive

:) I have a window with different controls that I want to be able to change styles to all controls - I created the default style settings as a variable that get loaded in from an external text file but this don't work...

$tm[6] = $BS_BOTTOM+$BS_FLAT

GUICtrlCreateButton ("Push style", 100 , 100, 100 , 22 , $tm[6] ) // works

$tm[6] = StringMid($tm[6],2,StringLen($tm[6])-2) // $BS_BOTTOM+$BS_FLAT

GUICtrlCreateButton ("Push style", 100 , 100, 100 , 22 , $tm[6] ) // don't work

Why is this - is it not posible to get control styles from external preferences file into an variable like in the last example or do I have to init this variable in some special manner something like a Value($tm[6]) - any suggestens! :D

Kåre

Edited by kjactive

Share this post


Link to post
Share on other sites
Coffee

There are a few problems here.

Firstly when combining styles always use Bitor($style, $style) and not $sytle+$style

You may store your values anywhere, be it in your script, .ini file, registry etc.

However to set a value to a variable you must use its value and not it's name.

This works:

#include <GUIConstants.au3>

$string = "0x0800+0x8000" 
$split = stringsplit($string, "+", 1) 

$gui = Guicreate("Mygui")

$button1 = GUICtrlCreateButton("Push Style", 10, 100, 70, 70, BitOR($split[1], $split[2]))

GUISetState()

while 1
    $msg = GUIGetMsg()
    
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        
        Case $msg = $button1
            MsgBox(0, "status", "yay! I look correct")
    EndSelect
WEnd

However this does not:

#include <GUIConstants.au3>

$string = "$BS_BOTTOM+$BS_FLAT"
$split = stringsplit($string, "+", 1)

$gui = Guicreate("Mygui")

$button1 = GUICtrlCreateButton("Push Style", 10, 100, 70, 70, BitOR($split[1] , $split[2]))


GUISetState()

while 1
    $msg = GUIGetMsg()
    
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        
        Case $msg = $button1
            MsgBox(0, "status", ":( I look fubar :(")
    EndSelect
WEnd

Share this post


Link to post
Share on other sites
kjactive

Thaks for your responce - I know that the $BS_BOTTOM etc. are variabes declared as globals in the #include <GUIConstants.au3> and as this should be available at all time internal in the script and my variables are strings but what I miss is a function to change my string into the variable like something like this variable $BS_BOTTOM = Value(string $BS_BOTTOM) - Is this not posible in au3, I tryed Eval and assign without luck and can't quiet get why as they are available globals...

Thanks for the correction on BitOr - Ofcourse...

Kåre

Edited by kjactive

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  

×