Jump to content

GUICtrlSetDefBkColor and GUICtrlSetImage


dasiuss
 Share

Recommended Posts

hi

i'm trying to do gui with all buttons and labels black, and with white text color.

but some buttons have img.

When i used GUICtrlSetDefBkColor nad/or GUICtrlSetDefColor buttons with img are black and with no icon.

in this situation must i use GUICtrlSetColor for each control? or maybe there is some other solution?

Link to comment
Share on other sites

I think this is a known bug with the buttons. You could use a function instead to make the buttons, so you don't have to set the color to every button.

GUICreate("Black")
;~ GUICtrlSetDefBkColor(0)
;~ GUICtrlSetDefColor(0xFFFFFF)

GUICtrlCreateButton("Button1", 20, 20)
GUICtrlCreateButton("Button2", 20, 50)
GUICtrlCreateButton("Button3", 20, 80)
GUICtrlCreateButton("Button4", 20, 110)

GUICtrlCreateButton("Button1", 120, 20, -1, -1, 0x0040)
GUICtrlSetImage(-1, "shell32.dll", Random(1, 22, 1))
GUICtrlCreateButton("Button2", 120, 50, -1, -1, 0x0040)
GUICtrlSetImage(-1, "shell32.dll", Random(1, 22, 1))
GUICtrlCreateButton("Button3", 120, 80, -1, -1, 0x0040)
GUICtrlSetImage(-1, "shell32.dll", Random(1, 22, 1))
GUICtrlCreateButton("Button4", 120, 110, -1, -1, 0x0040)
GUICtrlSetImage(-1, "shell32.dll", Random(1, 22, 1))

_MakeBlackButton("Button1", 220, 20)
_MakeBlackButton("Button2", 220, 50)
_MakeBlackButton("Button3", 220, 80)
_MakeBlackButton("Button4", 220, 110)

_MakeIconButton("Button1", 320, 20, "shell32.dll", Random(1, 22, 1))
_MakeIconButton("Button2", 320, 50, "shell32.dll", Random(1, 22, 1))
_MakeIconButton("Button3", 320, 80, "shell32.dll", Random(1, 22, 1))
_MakeIconButton("Button4", 320, 110, "shell32.dll", Random(1, 22, 1))

GUISetState()
Do
Until GUIGetMsg() = -3


Func _MakeBlackButton($sText, $left, $top, $width = Default, $height = Default, $style = -1, $exstyle = -1)
 GUICtrlCreateButton($sText, $left, $top, $width, $height, $style, $exstyle)
 GUICtrlSetBkColor(-1, 0)
 GUICtrlSetColor(-1, 0xFFFFFF)
EndFunc

Func _MakeIconButton($sText, $left, $top, $filename , $iconname = -1, $width = Default, $height = Default)
 GUICtrlCreateButton($sText, $left, $top, $width, $height, 0x0040)
 GUICtrlSetImage(-1, $filename, $iconname)
EndFunc

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

Yes Button colors are a bug. but that is why i use a Label/multilabels to make my custom buttons.. because its so much more customizable :) haha

and because i'm bored right now.. i will make a UDF for this lol

Link to comment
Share on other sites

well... it may not be what your looking for but it might help.

$gui = Guicreate (':o',200,50,-1,-1,-1,-1,Wingethandle ('[CLASS:Progman]',''))
$Button = _lButton ('BUTTON',20,20,100,20)
GUICtrlSetBkColor ($Button[1],0x414141)
GUICtrlSetBkColor ($Button[2],0x313131)
GUICtrlSetColor ($Button[3],0xFFFFFF)
GUisetstate ()
While GUIGetMsg () <> -3
wend
;=====================================================================================
;=========$Text = the text that the user has used=====================================
;=========$x = the X position on the current GUI form=================================
;=========$y = the Y position on the current GUI form=================================
;=========$w = how wide the "Button" is to be=========================================
;=========$h = how tall the "Button" is to be=========================================
;=====================================================================================
;=========RETURN value = an array consisting of the 1st 2nd and 3rd Labels============
;=========1st label has the TOP color=================================================
;=========2nd label has the BOTTOM color==============================================
;=========3rd label is transparent and is the one that has to have the Styles on it===
;=====================================================================================
;=====================================================================================
;=====================================================================================
Func _lButton ($Text,$x,$y,$w,$h)
    Local $CtrlID1, $CtrlID2, $CtrlID3
    $CtrlID1 = GUICtrlCreateLabel ('',$x,$y,$w,$h / 2)
    GUICtrlSetState (-1,128)
    $CtrlID2 = GUICtrlCreateLabel ('',$x,$y + $h / 2,$w,$h / 2)
    GUICtrlSetState (-1,128)
    $CtrlID3 = GUICtrlCreateLabel ('Text',$x,$y,$w,$h,BitOR (1, 0x0200),0x00000001)
    GUICtrlSetBkColor (-1,-2)
    GUICtrlSetCursor (-1,0)
    Return StringSplit ($CtrlID1 & ',' & $CtrlID2 & ',' & $CtrlID3,',')
EndFunc
Edited by CodyBarrett
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...