Jump to content

[solved]using an inf file to set GUI colors


Recommended Posts

hey guys i need help, i have managed to diplay a color value in Hex from my inf file in a msgbox, the msgbox is to show me that i have called the value part of the string in the inf file using stringright, what i want to do is create a GUI with that color, currently the GUI is made Black, i want it to come up as a light blue color to this value: 0A9DFF (value is in Hex)

i am working in a GUI customization script

here is the code:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiButton.au3>
#Include <File.au3>
#Include <Array.au3>

dim $cArray

$scount = 6
$inf = @scriptdir & "\guisets.inf"

_FileReadToArray($inf, $cArray)
$string=_ArrayToString($cArray)
StringSplit($string, "=")
$sdis=StringRight($cArray[1],$scount)
msgbox(0,"",$sdis)

$guicolor= $cArray

$gui=GUICreate("testGui",600,600)
GUISetState(@sw_show,$gui)
GUISetBkColor(StringRight($cArray[1],$scount),$gui)

while 1
    $msg = GUIGetMsg()
    
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
GUIDelete()

and attached is the INF file i am working off, i have only filled in the value of one line as all i need is to find the right code, then the rest will work

thanks in advance

*edit* cannot upload file, here it is in code

guisets.inf:

background=0A9DFF
buttons=
labels=
Edited by snowman533

Intermediate AutoIt/Autohotkey User

Link to comment
Share on other sites

Why don't you use the ....IniRead ... IniWrite ... ? ;)^_^

Check the user manual if you like for this solution !

[s][font="Impact"]░▒▓▓►DrKovra◄▓▓▒░[/font][/s]The only thing I [sup]know [/sup]is that I don't know [sub]nothing[/sub]--------------- __________------------------------------ __________---------------

Link to comment
Share on other sites

  • Moderators

snowman533,

If you decide to follow DrKovra's excellent advice, you might like to look at this short inifile example I have just posted in another thread. It will give you a good idea of how to use ini files (I hope ;-))

M23.

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

still not displaying right, still coming up as black

trashed the array section of code

new code:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiButton.au3>
#Include <File.au3>

$ini = @scriptdir & "\guisets.ini"

$gui=GUICreate("testGui",600,600)
GUISetState(@sw_show,$gui)
$color=IniRead($ini, "colors", "background", "Error")
GUISetBkColor(hex($color),$gui)
MsgBox(0,"",IniRead($ini, "colors", "background", "Error"))

while 1
    $msg = GUIGetMsg()
    
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
GUIDelete()

msgbox returns correct value from ini file, a troubleshooter that tells me i am still missing something but i cant find it, and no help file entries help

please help me, what am i missing? thanks in advance

guisets.ini

[colors]
background=0A9DFF
buttons=
labels=
Edited by snowman533

Intermediate AutoIt/Autohotkey User

Link to comment
Share on other sites

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiButton.au3>
#Include <File.au3>

$ini = @scriptdir & "\guisets.ini"

$gui=GUICreate("testGui",600,600)
GUISetState(@sw_show,$gui)
$color=IniRead($ini, "colors", "background", "Error")
GUISetBkColor('0x'&$color,$gui)
MsgBox(0,"",IniRead($ini, "colors", "background", "Error"))

while 1
    $msg = GUIGetMsg()
    
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
GUIDelete()

Instead of using Hex($color) use this, cause the color code is allready hex() ^_^ You just needed to add 0x in front of it:P

Link to comment
Share on other sites

still not displaying right, still coming up as black

trashed the array section of code

new code:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiButton.au3>
#Include <File.au3>

$ini = @scriptdir & "\guisets.ini"

$gui=GUICreate("testGui",600,600)
GUISetState(@sw_show,$gui)
$color=IniRead($ini, "colors", "background", "Error")
GUISetBkColor(hex($color),$gui)
MsgBox(0,"",IniRead($ini, "colors", "background", "Error"))

while 1
    $msg = GUIGetMsg()
    
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
GUIDelete()

msgbox returns correct value from ini file, a troubleshooter that tells me i am still missing something but i cant find it, and no help file entries help

please help me, what am i missing? thanks in advance

guisets.ini

[colors]
background=0A9DFF
buttons=
labels=
hi,

your problem is, that background=0A9DFF is a hex. If you use Hex ("0A9DFF") you get 00000000 as return.

If you replace 0A9DFF with 695807 in your ini file it should work.

;-))

Stefan

Link to comment
Share on other sites

@BlackPheonix:

thanks that worked, i added 0x to the entry in the ini file ^_^

@99ojo:

thanks your solution also worked, now to decide which method to use ;)

solved

Edited by snowman533

Intermediate AutoIt/Autohotkey User

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...