Jump to content

Problem changing group and checkbox text colour


shanet
 Share

Recommended Posts

Hi guys,

Been a while since I was last using AutoIt properly and it's showing!

I am creating a simple game launcher - before you all pounce, this is not a hack. I will use it to pass command line parameters to a game. Not to hack it.

Anyway, I have loaded the background image and have a button displayed - however the text on both the checkbox and group will not change?

Looking through the help file, I noted:

Only Button, Label, Checkbox, Group, Radio, Edit, Input, List, Listview, ListviewItem, Treeview, TreeviewItem, Graphic, Progress and Combo controls can currently be colored.

Checkbox, Radio, Group or Progress controls cannot be painted if the "Windows XP/Vista style" is used.

That sort of contradicts itself? My brother tried to show me optional 'workarounds' however neither of them suited what I want to do. So here is the program. Works the same without the background image.

#include <GDIPlus.au3>
#include <WinAPI.au3>

Global $hGUI, $hImage, $hGraphic, $hLabel
Global $hRunGroup, $hRun, $hRunTesting

; Create GUI
$hGUI = GuiCreate("Assaultcube Launcher", 400, 400)
;~   GUICtrlSetDefColor(0xFFFFFF, $hGUI)
  GUISetBkColor(0x000000, $hGUI)
GUISetState()

; Create background image
_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile("C:\Program Files\AssaultCube_v1.1.0.4\packages\misc\startscreen.png")
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, 10, -20, 380, 380)

; Hide Loading... text
GUICtrlCreateLabel("", 130, 180, 120, 30)
GUICtrlSetBkColor(-1, 0x000000)

; Create controls
$hRunGroup = GUICtrlCreateGroup("Run Assaultcube", 10, 250, 380, 50)
$hRun = GUICtrlCreateButton("Run Assaultcube", 40, 300)
$hRunTesting = GUICtrlCreateCheckbox("Testing", 100, 100)

; Set appropriate colours
GUICtrlSetColor($hRunGroup, 0xFFFFFF)
GUICtrlSetColor($hRun, 0x000000 )
GUICtrlSetColor($hRunTesting, 0xFFFFFF)

While 1
switch GUIGetMsg()
case -3
_Exit()
EndSwitch

WEnd

Func _Exit()
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_ShutDown()
Exit
EndFunc

Can anyone help me to set the group and checkbox text colours please? Please note the background colours must stay the same.

[font="Comic Sans MS"]My code does not have bugs! It just develops random features.[/font]My Projects[list][*]Live Streaming (Not my project, but my edited version)[right]AutoIt Wrappers![/right][/list]Pure randomness[list][*]Small Minds.......................................................................................................[size="1"]Simple progress bar that changes direction at either sides.[/size][*]ChristmasIt AutoIt Christmas Theme..........................................................[size="1"]I WAS BOOOORED![/size][*]DriveToy..............................................................................................................[size="1"]Simple joke script. Trick your friends into thinking their computer drive is haywire![/size][/list]In Development[list][*]Your Background Task Organiser[*]AInstall Second Generation[/list]BEFORE POSTING ON THE FORUMS, TRY THIS:

%programfiles%/AutoIt3/autoit3.chm
Link to comment
Share on other sites

  • Moderators

shanet,

Next time just write a short script showing the problem that does not even mention games and then you will not have to go through the explanation and I will not get reports about the thread - makes us both happy. :)

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

Ok, I apologise for that. Any ideas Melba?

[font="Comic Sans MS"]My code does not have bugs! It just develops random features.[/font]My Projects[list][*]Live Streaming (Not my project, but my edited version)[right]AutoIt Wrappers![/right][/list]Pure randomness[list][*]Small Minds.......................................................................................................[size="1"]Simple progress bar that changes direction at either sides.[/size][*]ChristmasIt AutoIt Christmas Theme..........................................................[size="1"]I WAS BOOOORED![/size][*]DriveToy..............................................................................................................[size="1"]Simple joke script. Trick your friends into thinking their computer drive is haywire![/size][/list]In Development[list][*]Your Background Task Organiser[*]AInstall Second Generation[/list]BEFORE POSTING ON THE FORUMS, TRY THIS:

%programfiles%/AutoIt3/autoit3.chm
Link to comment
Share on other sites

It's not a contradiction, you just need to disable theming to set colors for them.

Here's an example of mine I like to quote when this turns up.

You can make only the group-control run without any theme by doing like so:

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>

$Form1_1 = GUICreate("Amortization Plus", 644, 303, 207, 200)
GUISetBkColor(0x000080)
$Group1 = GUICtrlCreateGroup("Amortization Table", 8, 0, 625, 81, BitOR($BS_CENTER, $BS_FLAT))
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($Group1), "wstr", 0, "wstr", 0)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetFont(-1, 10, 400, 0, "System")

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

(this of course also works on Checkbox, Radio and Progress)

Or disable it for the whole gui like so:

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>

DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)

$Form1_1 = GUICreate("Amortization Plus", 644, 303, 207, 200)
GUISetBkColor(0x000080)
$Group1 = GUICtrlCreateGroup("Amortization Table", 8, 0, 625, 81, BitOR($BS_CENTER, $BS_FLAT))
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetFont(-1, 10, 400, 0, "System")

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Link to comment
Share on other sites

Func StyleToggle($Off = 1)
If Not StringInStr(@OSType, "WIN32_NT") Then Return 0
$XS_n = DllCall("uxtheme.dll", "int", "GetThemeAppProperties")
If $Off Then
  DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)
  Return 1
ElseIf IsArray($XS_n) Then
  DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", $XS_n[0])
  $XS_n = ""
  Return 1
EndIf
Return 0
EndFunc   ;==>StyleToggle

you can use this!

Example:

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>

StyleToggle(1)
$Form1_1 = GUICreate("Amortization Plus", 644, 303, 207, 200)
GUISetBkColor(0x000080)
$Group1 = GUICtrlCreateGroup("Amortization Table", 8, 0, 625, 81, BitOR($BS_CENTER, $BS_FLAT))
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetFont(-1, 10, 400, 0, "System")
StyleToggle(0)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
EndSwitch
WEnd

Func StyleToggle($Off = 1)
If Not StringInStr(@OSType, "WIN32_NT") Then Return 0
$XS_n = DllCall("uxtheme.dll", "int", "GetThemeAppProperties")
If $Off Then
  DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)
  Return 1
ElseIf IsArray($XS_n) Then
  DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", $XS_n[0])
  $XS_n = ""
  Return 1
EndIf
Return 0
EndFunc   ;==>StyleToggle
Edited by golfinhu
Link to comment
Share on other sites

AdmiralWithHat, many thanks for that DllCall. Works like a charm.

Maybe that should be included in the help file? If it is, I apologise for missing it.

Thanks guys!

[font="Comic Sans MS"]My code does not have bugs! It just develops random features.[/font]My Projects[list][*]Live Streaming (Not my project, but my edited version)[right]AutoIt Wrappers![/right][/list]Pure randomness[list][*]Small Minds.......................................................................................................[size="1"]Simple progress bar that changes direction at either sides.[/size][*]ChristmasIt AutoIt Christmas Theme..........................................................[size="1"]I WAS BOOOORED![/size][*]DriveToy..............................................................................................................[size="1"]Simple joke script. Trick your friends into thinking their computer drive is haywire![/size][/list]In Development[list][*]Your Background Task Organiser[*]AInstall Second Generation[/list]BEFORE POSTING ON THE FORUMS, TRY THIS:

%programfiles%/AutoIt3/autoit3.chm
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

×
×
  • Create New...