Jump to content

Recommended Posts

Posted (edited)

I tryed to search in forum and in help file but maybe that is my problem at the end xD.

 

 

I whould like to modify the color of the group background only

 

I got a palliative sollution to make a label and set the backgroud color of the label but it gonna make me add a label again etc for the complet gui (i make my gui alone always , not with KODA) 

 

I whould like to know if there is a AI function to do that i have missing.

 

something like ..../

GuiCtrlSetGroupBackgroundColor , 0x000000

 

or maybe a solution that is more easy than making again all my label with background

 

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Posted

Here's an example using an array to hold the labels

#include <GUIConstants.au3>
#include <AutoItConstants.au3>

Global $hMain = GUICreate("", 420, 420)
Global $aLabels[10][10]
Global $iXOffset = 20
Global $iYOffset = 20

For $i = 0 To UBound($aLabels, $UBOUND_ROWS) - 1
    For $j = 0 To UBound($aLabels, $UBOUND_COLUMNS) - 1
        $aLabels[$i][$j] = GUICtrlCreateLabel("", $iXOffset, $iYOffset, 20, 20)
        $iXOffset += 40
    Next
    $iYOffset += 40
    $iXOffset = 20
Next

SetLabels($aLabels, 0xFF0000)

GUISetState(@SW_SHOW, $hMain)

While (True)
    Switch (GUIGetMsg())
        Case $GUI_EVENT_CLOSE
            Exit 0
    EndSwitch
WEnd

Func SetLabels(Const ByRef $aLabels, Const $iColor)
    For $i = 0 To UBound($aLabels, $UBOUND_ROWS) - 1
        For $j = 0 To UBound($aLabels, $UBOUND_COLUMNS) - 1
            GUICtrlSetBkColor($aLabels[$i][$j], $iColor)
        Next
    Next
EndFunc   ;==>SetLabels

Here's an example using a set of labels

#include <GUIConstants.au3>
#include <AutoItConstants.au3>

Global $hMain = GUICreate("", 420, 420)
Global $lblLabel1 = GUICtrlCreateLabel("", 20, 20, 20, 20)
Global $lblLabel2 = GUICtrlCreateLabel("", 60, 20, 20, 20)
Global $lblLabel3 = GUICtrlCreateLabel("", 100, 20, 20, 20)
Global $lblLabel4 = GUICtrlCreateLabel("", 140, 20, 20, 20)
Global $lblLabel5 = GUICtrlCreateLabel("", 180, 20, 20, 20)
Global $lblLabel6 = GUICtrlCreateLabel("", 220, 20, 20, 20)
Global $lblLabel7 = GUICtrlCreateLabel("", 260, 20, 20, 20)
Global $lblLabel8 = GUICtrlCreateLabel("", 300, 20, 20, 20)
Global $lblLabel9 = GUICtrlCreateLabel("", 340, 20, 20, 20)
Global $lblLabel10 = GUICtrlCreateLabel("", 380, 20, 20, 20)
Global $lblLabel11 = GUICtrlCreateLabel("", 20, 60, 20, 20)
Global $lblLabel12 = GUICtrlCreateLabel("", 60, 60, 20, 20)
Global $lblLabel13 = GUICtrlCreateLabel("", 100, 60, 20, 20)
Global $lblLabel14 = GUICtrlCreateLabel("", 140, 60, 20, 20)
Global $lblLabel15 = GUICtrlCreateLabel("", 180, 60, 20, 20)
Global $lblLabel16 = GUICtrlCreateLabel("", 220, 60, 20, 20)
Global $lblLabel17 = GUICtrlCreateLabel("", 260, 60, 20, 20)
Global $lblLabel18 = GUICtrlCreateLabel("", 300, 60, 20, 20)
Global $lblLabel19 = GUICtrlCreateLabel("", 340, 60, 20, 20)
Global $lblLabel20 = GUICtrlCreateLabel("", 380, 60, 20, 20)
Global $lblLabel21 = GUICtrlCreateLabel("", 20, 100, 20, 20)
Global $lblLabel22 = GUICtrlCreateLabel("", 60, 100, 20, 20)
Global $lblLabel23 = GUICtrlCreateLabel("", 100, 100, 20, 20)
Global $lblLabel24 = GUICtrlCreateLabel("", 140, 100, 20, 20)
Global $lblLabel25 = GUICtrlCreateLabel("", 180, 100, 20, 20)
Global $lblLabel26 = GUICtrlCreateLabel("", 220, 100, 20, 20)
Global $lblLabel27 = GUICtrlCreateLabel("", 260, 100, 20, 20)
Global $lblLabel28 = GUICtrlCreateLabel("", 300, 100, 20, 20)
Global $lblLabel29 = GUICtrlCreateLabel("", 340, 100, 20, 20)
Global $lblLabel30 = GUICtrlCreateLabel("", 380, 100, 20, 20)
Global $lblLabel31 = GUICtrlCreateLabel("", 20, 140, 20, 20)
Global $lblLabel32 = GUICtrlCreateLabel("", 60, 140, 20, 20)
Global $lblLabel33 = GUICtrlCreateLabel("", 100, 140, 20, 20)
Global $lblLabel34 = GUICtrlCreateLabel("", 140, 140, 20, 20)
Global $lblLabel35 = GUICtrlCreateLabel("", 180, 140, 20, 20)
Global $lblLabel36 = GUICtrlCreateLabel("", 220, 140, 20, 20)
Global $lblLabel37 = GUICtrlCreateLabel("", 260, 140, 20, 20)
Global $lblLabel38 = GUICtrlCreateLabel("", 300, 140, 20, 20)
Global $lblLabel39 = GUICtrlCreateLabel("", 340, 140, 20, 20)
Global $lblLabel40 = GUICtrlCreateLabel("", 380, 140, 20, 20)
Global $lblLabel41 = GUICtrlCreateLabel("", 20, 180, 20, 20)
Global $lblLabel42 = GUICtrlCreateLabel("", 60, 180, 20, 20)
Global $lblLabel43 = GUICtrlCreateLabel("", 100, 180, 20, 20)
Global $lblLabel44 = GUICtrlCreateLabel("", 140, 180, 20, 20)
Global $lblLabel45 = GUICtrlCreateLabel("", 180, 180, 20, 20)
Global $lblLabel46 = GUICtrlCreateLabel("", 220, 180, 20, 20)
Global $lblLabel47 = GUICtrlCreateLabel("", 260, 180, 20, 20)
Global $lblLabel48 = GUICtrlCreateLabel("", 300, 180, 20, 20)
Global $lblLabel49 = GUICtrlCreateLabel("", 340, 180, 20, 20)
Global $lblLabel50 = GUICtrlCreateLabel("", 380, 180, 20, 20)
Global $lblLabel51 = GUICtrlCreateLabel("", 20, 220, 20, 20)
Global $lblLabel52 = GUICtrlCreateLabel("", 60, 220, 20, 20)
Global $lblLabel53 = GUICtrlCreateLabel("", 100, 220, 20, 20)
Global $lblLabel54 = GUICtrlCreateLabel("", 140, 220, 20, 20)
Global $lblLabel55 = GUICtrlCreateLabel("", 180, 220, 20, 20)
Global $lblLabel56 = GUICtrlCreateLabel("", 220, 220, 20, 20)
Global $lblLabel57 = GUICtrlCreateLabel("", 260, 220, 20, 20)
Global $lblLabel58 = GUICtrlCreateLabel("", 300, 220, 20, 20)
Global $lblLabel59 = GUICtrlCreateLabel("", 340, 220, 20, 20)
Global $lblLabel60 = GUICtrlCreateLabel("", 380, 220, 20, 20)
Global $lblLabel61 = GUICtrlCreateLabel("", 20, 260, 20, 20)
Global $lblLabel62 = GUICtrlCreateLabel("", 60, 260, 20, 20)
Global $lblLabel63 = GUICtrlCreateLabel("", 100, 260, 20, 20)
Global $lblLabel64 = GUICtrlCreateLabel("", 140, 260, 20, 20)
Global $lblLabel65 = GUICtrlCreateLabel("", 180, 260, 20, 20)
Global $lblLabel66 = GUICtrlCreateLabel("", 220, 260, 20, 20)
Global $lblLabel67 = GUICtrlCreateLabel("", 260, 260, 20, 20)
Global $lblLabel68 = GUICtrlCreateLabel("", 300, 260, 20, 20)
Global $lblLabel69 = GUICtrlCreateLabel("", 340, 260, 20, 20)
Global $lblLabel70 = GUICtrlCreateLabel("", 380, 260, 20, 20)
Global $lblLabel71 = GUICtrlCreateLabel("", 20, 300, 20, 20)
Global $lblLabel72 = GUICtrlCreateLabel("", 60, 300, 20, 20)
Global $lblLabel73 = GUICtrlCreateLabel("", 100, 300, 20, 20)
Global $lblLabel74 = GUICtrlCreateLabel("", 140, 300, 20, 20)
Global $lblLabel75 = GUICtrlCreateLabel("", 180, 300, 20, 20)
Global $lblLabel76 = GUICtrlCreateLabel("", 220, 300, 20, 20)
Global $lblLabel77 = GUICtrlCreateLabel("", 260, 300, 20, 20)
Global $lblLabel78 = GUICtrlCreateLabel("", 300, 300, 20, 20)
Global $lblLabel79 = GUICtrlCreateLabel("", 340, 300, 20, 20)
Global $lblLabel80 = GUICtrlCreateLabel("", 380, 300, 20, 20)
Global $lblLabel81 = GUICtrlCreateLabel("", 20, 340, 20, 20)
Global $lblLabel82 = GUICtrlCreateLabel("", 60, 340, 20, 20)
Global $lblLabel83 = GUICtrlCreateLabel("", 100, 340, 20, 20)
Global $lblLabel84 = GUICtrlCreateLabel("", 140, 340, 20, 20)
Global $lblLabel85 = GUICtrlCreateLabel("", 180, 340, 20, 20)
Global $lblLabel86 = GUICtrlCreateLabel("", 220, 340, 20, 20)
Global $lblLabel87 = GUICtrlCreateLabel("", 260, 340, 20, 20)
Global $lblLabel88 = GUICtrlCreateLabel("", 300, 340, 20, 20)
Global $lblLabel89 = GUICtrlCreateLabel("", 340, 340, 20, 20)
Global $lblLabel90 = GUICtrlCreateLabel("", 380, 340, 20, 20)
Global $lblLabel91 = GUICtrlCreateLabel("", 20, 380, 20, 20)
Global $lblLabel92 = GUICtrlCreateLabel("", 60, 380, 20, 20)
Global $lblLabel93 = GUICtrlCreateLabel("", 100, 380, 20, 20)
Global $lblLabel94 = GUICtrlCreateLabel("", 140, 380, 20, 20)
Global $lblLabel95 = GUICtrlCreateLabel("", 180, 380, 20, 20)
Global $lblLabel96 = GUICtrlCreateLabel("", 220, 380, 20, 20)
Global $lblLabel97 = GUICtrlCreateLabel("", 260, 380, 20, 20)
Global $lblLabel98 = GUICtrlCreateLabel("", 300, 380, 20, 20)
Global $lblLabel99 = GUICtrlCreateLabel("", 340, 380, 20, 20)
Global $lblLabel100 = GUICtrlCreateLabel("", 380, 380, 20, 20)

For $i = $lblLabel1 To $lblLabel10
    GUICtrlSetBkColor($i, 0xFFFFFF)
Next

For $i = $lblLabel11 To $lblLabel20
    GUICtrlSetBkColor($i, 0)
Next

For $i = $lblLabel21 To $lblLabel30
    GUICtrlSetBkColor($i, 0xFF0000)
Next

For $i = $lblLabel31 To $lblLabel40
    GUICtrlSetBkColor($i, 0x00FF00)
Next

For $i = $lblLabel41 To $lblLabel50
    GUICtrlSetBkColor($i, 0x0000FF)
Next

For $i = $lblLabel51 To $lblLabel60
    GUICtrlSetBkColor($i, 0x678912)
Next

For $i = $lblLabel61 To $lblLabel70
    GUICtrlSetBkColor($i, 0x11F8CC)
Next

For $i = $lblLabel71 To $lblLabel80
    GUICtrlSetBkColor($i, 0x888888)
Next

For $i = $lblLabel81 To $lblLabel90
    GUICtrlSetBkColor($i, 0xF04444)
Next

For $i = $lblLabel91 To $lblLabel100
    GUICtrlSetBkColor($i, 0x444FFF)
Next

GUISetState(@SW_SHOW, $hMain)

While (True)
    Switch (GUIGetMsg())
        Case $GUI_EVENT_CLOSE
            Exit 0
    EndSwitch
WEnd

 

Posted

Dear InunoTaishou

 

Sorry for my english.

This isexactly what i am using in my script without any advise that's funny.

But it s not what i am requesting.

 

I am gonna post some of my groups label so may you will understand better what i am asking.  and iknow i can solve the problem with a label font but i just whould like to know if there is a way to set the backgroud color of a

GUICtrlCreateGroup

And nothing else

 

Here is a part of my script (i assume you know everything about include etc so i wont post the total script) but i can post it without any restriction but i have to protect my company private datas so i prefer dont do it or i will have to correct all privacy code.

#include <Misc.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <File.au3>
#include <Word.au3>
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <ColorConstantS.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <ListViewConstants.au3>
#include <GuiListView.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <_IsUacAdmin.au3>
#include <AD.au3>

Global $GUI = GUICreate("Opticiens-Atol", 800, 600)

$Font1 = GUICtrlCreateLabel  ( "" , 5 , 5 , 185 , 130 )
   GUICtrlSetBkColor ( $Font1 , 0x4486FA );Bleu google

$Groupe1 = GUICtrlCreateGroup ( "Office1" , 5 , 5 , 190 , 135 ) ;Groupe OFFICE
      $Groupe2 = GUICtrlCreateGroup ( "Utilisateur2" , 200 , 5 , 200 , 195 ) ;Groupe Utilisateur
         $Groupe3 = GUICtrlCreateGroup ( "Accés réseau3" , 405 , 5 , 390 , 120 ) ;Groupe RESEAU
            $Groupe4 = GUICtrlCreateGroup ( "Lecture AD4" , 405 , 125 , 390 , 75 ) ;Groupe RESEAU

            GUISetState(@SW_SHOW, $GUI)

While (1)

   Sleep (2000)

WEnd

 

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Posted (edited)

Oh.. the group control, I thought it was a group of controls. Something like this maybe?

#include <Misc.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <File.au3>
#include <Word.au3>
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <ColorConstantS.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <ListViewConstants.au3>
#include <GuiListView.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>

Global $GUI = GUICreate("Opticiens-Atol", 800, 600)

$Font1 = GUICtrlCreateLabel("", 5, 5, 185, 130)


$Groupe1 = GUICtrlCreateGroup("Office1", 5, 5, 190, 135) ;Groupe OFFICE
$Groupe2 = GUICtrlCreateGroup("Utilisateur2", 200, 5, 200, 195) ;Groupe Utilisateur
$Groupe3 = GUICtrlCreateGroup("Accés réseau3", 405, 5, 390, 120) ;Groupe RESEAU
$Groupe4 = GUICtrlCreateGroup("Lecture AD4", 405, 125, 390, 75) ;Groupe RESEAU

GUICtrlSetGroupBkColor($Groupe1, 0x4486FA)

GUISetState(@SW_SHOW, $GUI)

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

Func GUICtrlSetGroupBkColor(Const $iCtrl, Const $iColor)
    Local Static $iBorder = 4   ; Border of the group control, this is the grey line around the edges
    Local Static $iYOffset = 14 ; Y offset to account for the text in the group control
    Local $hWnd = IsHWnd($iCtrl) ? $iCtrl : GUICtrlGetHandle($iCtrl)    ; Handle used to get the control position
    Local $aCtrlArea = ControlGetPos(_WinAPI_GetParent($hWnd), "", $iCtrl)  ; Get the control position
    Local $lblReturn = GUICtrlCreateLabel("", $aCtrlArea[0] + $iBorder, $aCtrlArea[1] + $iYOffset, $aCtrlArea[2] - $iBorder * 2, $aCtrlArea[3] - $iYOffset - $iBorder)  ; Create a label that's used for the back color inside the group control
    GUICtrlSetColor($lblReturn, $iColor)
    GUICtrlSetBkColor($lblReturn, $iColor)
    GUICtrlSetState($lblReturn, $GUI_DISABLE)
    GUICtrlSetBkColor($iCtrl, $iColor)
    Return $lblReturn   ; Return the label, can be stored and used to update the color of this group later
EndFunc   ;==>GUICtrlSetGroupBkColor#include <Misc.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <File.au3>
#include <Word.au3>
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <ColorConstantS.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <ListViewConstants.au3>
#include <GuiListView.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>

Global $GUI = GUICreate("Opticiens-Atol", 800, 600)

$Font1 = GUICtrlCreateLabel("", 5, 5, 185, 130)


$Groupe1 = GUICtrlCreateGroup("Office1", 5, 5, 190, 135) ;Groupe OFFICE
$Groupe2 = GUICtrlCreateGroup("Utilisateur2", 200, 5, 200, 195) ;Groupe Utilisateur
$Groupe3 = GUICtrlCreateGroup("Accés réseau3", 405, 5, 390, 120) ;Groupe RESEAU
$Groupe4 = GUICtrlCreateGroup("Lecture AD4", 405, 125, 390, 75) ;Groupe RESEAU

GUICtrlSetGroupBkColor($Groupe1, 0x4486FA)

GUISetState(@SW_SHOW, $GUI)

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

Func GUICtrlSetGroupBkColor(Const $iCtrl, Const $iColor)
    Local Static $iBorder = 4   ; Border of the group control, this is the grey line around the edges
    Local Static $iYOffset = 14 ; Y offset to account for the text in the group control
    Local $hWnd = IsHWnd($iCtrl) ? $iCtrl : GUICtrlGetHandle($iCtrl)    ; Handle used to get the control position
    Local $aCtrlArea = ControlGetPos(_WinAPI_GetParent($hWnd), "", $iCtrl)  ; Get the control position
    Local $lblReturn = GUICtrlCreateLabel("", $aCtrlArea[0] + $iBorder, $aCtrlArea[1] + $iYOffset, $aCtrlArea[2] - $iBorder * 2, $tCtrlArea[3] - $iYOffset - $iBorder)  ; Create a label that's used for the back color inside the group control
    GUICtrlSetColor($lblReturn, $iColor)
    GUICtrlSetBkColor($lblReturn, $iColor)
    GUICtrlSetState($lblReturn, $GUI_DISABLE)
    GUICtrlSetBkColor($iCtrl, $iColor)
    Return $lblReturn   ; Return the label, can be stored and used to update the color of this group later
EndFunc   ;==>GUICtrlSetGroupBkColor

You might get a more desirable result if you just created a square using some labels and using them as the border for your "group" and then you can create another label for the actual background of the group.

Edited by InunoTaishou
Posted

Yeah lol like that it s perfect/ wow...

But waw i thougth

GUICtrlSetGroupBkColor

gonna be enouth to do all that. Too much code for too low improvement about the gui colors./

 

The double label i much much more easyer. (if we do the label background FIRST and we dont change label after it s not buggy .)

I have to read your code and translate that in my head to see if i can reduce that i got only 4 group label but.... for my future code it s too much.

well you gift me a solution so. i am gonna edit as solved but i dont like that way. TY man.

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Posted (edited)

you're one of the best ;) Thank 1000x man

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

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
×
×
  • Create New...