Jump to content

Colored Buttons


GaryFrost
 Share

Recommended Posts

Function call format:

_GuiCtrlCreateButton($s_text, $x, $y, $width, $height[, $text_color = -1[, $back_color = -1[, $text_color_disabled = -1[, $back_color_disabled = -1[, $b_RGB = True]]]]])
oÝ÷ Ù«­¢+Ø)}Õ¥
Ñɱ  ÕÑѽ¹MÑQáÑ
½±½È ÀÌØí¹
Ñɱ%°ÀÌØíÑáÑ}½±½Él°ÀÌØíÑáÑ}½±½É}¥Í±ô´Ål°ÀÌØí}IôQÉÕut¤oÝ÷ Ù«­¢+Ø)}Õ¥
Ñɱ  ÕÑѽ¹MÑ   ­
½±½È ÀÌØí¹
Ñɱ%°ÀÌØí­}½±½Él°ÀÌØí­}½±½É}¥Í±ô´Ål°ÀÌØí}IôQÉÕut¤(oÝ÷ Ù«­¢+Ø)}Õ¥
Ñɱ  ÕÑѽ¹ÑQáÐ ÀÌØí¹
Ñɱ%¤(oÝ÷ Ù«­¢+Ø)}Õ¥
Ñɱ  ÕÑѽ¹MÑQáÐ ÀÌØí¹
Ñɱ%°ÀÌØíÍ}9ÝQáФ(

by default the colors passed in will be rgb colors

if you wish to use bgr colors, set the last param to False

default colors use -1

see example

I'm sure there is room for improvement, suggestions/help welcome.

Enjoy!!!

Gary

Edit: Updated the scripts with my latest ones, and added the 12 button test script.

Edit: Updated scripts for custom disabled colors

Edit: Added _GuiCtrlButtonSetTextColor and _GuiCtrlButtonSetBkColor functions

Edit: Added _GuiCtrlButtonGetText and _GuiCtrlButtonSetText functions

http://www.autoitscript.com/fileman/users/gafrost/projects/OwnerDrawnButtons/12_Buttons.au3

http://www.autoitscript.com/fileman/users/gafrost/projects/OwnerDrawnButtons/12button.PNG

http://www.autoitscript.com/fileman/users/gafrost/projects/OwnerDrawnButtons/Test_Button.au3

http://www.autoitscript.com/fileman/users/gafrost/projects/OwnerDrawnButtons/buttons.PNG

Include file http://www.autoitscript.com/fileman/users/gafrost/projects/OwnerDrawnButtons/GuiButton.au3

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

this makes it ALOT easier. well done gafrost

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Link to comment
Share on other sites

  • 2 weeks later...

i made an approach from a different, simpler angle...

it is not perfect yet, but it's a start... :-)

#include <GUIConstants.au3>

GUICreate("test",300,100)
$a = _GUICtrlCreateColorButton("test1",   5, 5, 50, 20,0xff0000)
$b = _GUICtrlCreateColorButton("test2",  65, 5, 50, 20,0x00ff00)
$c = _GUICtrlCreateColorButton("test3", 125, 5, 50, 20,0x0000ff,0xffffff)
$d = _GUICtrlCreateColorButton("test4", 185, 5, 50, 20,0xffff00)
$e = _GUICtrlCreateColorButton("test5", 245, 5, 50, 20,0xffffff)
GUICtrlCreateLabel("Colorbuttons - by rakudave, Pangaea WorX",50,50)
GUISetState ()

do
   $msg = GUIGetMsg()
    if $msg = $a[0] then msgbox(0,"colorbutton pressed","You pressed cb1")
    if $msg = $b[0] then msgbox(0,"colorbutton pressed","You pressed cb2")
    if $msg = $c[0] then msgbox(0,"colorbutton pressed","You pressed cb3")
    if $msg = $d[0] then msgbox(0,"colorbutton pressed","You pressed cb4")
    if $msg = $e[0] then msgbox(0,"colorbutton pressed","You pressed cb5")
until $msg = $GUI_EVENT_CLOSE

;#include-once
;=============================================================================
;
; Function Name:   _GUICtrlCreateColorButton()
;
; Description:   Creates a colored Button
;
; Syntax:         _GUICtrlCreateColorButton($text, $left, $top, $width, $height,$bkcolor[,$fontcolor])
;
; Parameter(s);     $text = The text of the control
;                   $left = The left side of the control
;                   $top = The top of the control
;                   $width = The width of the control
;                   $height = The height of the control
;                   $bkcolor = Backgroundcolor of the control
;                   $fontcolor = [optional] Fontcolor of the control
;
; Return Value(s):  array[1] = used to change colors
;                   array[0] = notifies GUIGetMsg if user clicks
;
; Author:          rakudave <rakudave@gmx.net>
;=============================================================================


Func _GUICtrlCreateColorButton($text, $left, $top, $width, $height,$bkcolor,$fontcolor = 0x000000)
local $colbut[2]
$colbut[0] = GUICtrlCreateLabel("",$left,$top,$width,$height,$SS_BLACKRECT)
GUICtrlCreateLabel("",$left,$top,$width -1,$height -1,$SS_WHITERECT)
GUICtrlCreateLabel("",$left +1,$top +1,$width -2,$height -2,$SS_GRAYRECT)
$colbut[1] = GUICtrlCreateLabel($text,$left +1,$top + 1,$width -3,$height -3,$SS_NOTIFY & $SS_CENTER)
GUICtrlSetBkColor(-1,$bkcolor)
GUICtrlSetColor(-1,$fontcolor)
Return $colbut
EndFunc
Link to comment
Share on other sites

  • Moderators

<-bump->

any word if this bug as been fixed?

http://www.autoitscript.com/forum/index.ph...ndpost&p=175930

@slightly_abnormal - Gary made this thread on the 21st, and Holger made this post: http://www.autoitscript.com/forum/index.ph...ndpost&p=176392 on the 23rd.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

i made an approach from a different, simpler angle...

it is not perfect yet, but it's a start... :-)

Thanks, but we are looking to use true buttons, not labels

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

i made an approach from a different, simpler angle...

it is not perfect yet, but it's a start... :-)

rakudave,

This looks like something I can work with. I will give it a closer look next week after I finish moving to my new house.

Thanks for taking a different approach as a work around.

taurus905

"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Link to comment
Share on other sites

rakudave sent me this code:

#include <GUIConstants.au3>

GUICreate("test",300,100)
$a = _GUICtrlCreateColorButton("test1",   5, 5, 50, 20, 0xff0000)
$b = _GUICtrlCreateColorButton("test2",  65, 5, 50, 20, 0x00ff00)
$c = _GUICtrlCreateColorButton("test3", 125, 5, 50, 20, 0x0000ff,0xffffff)
$d = _GUICtrlCreateColorButton("test4", 185, 5, 50, 20, 0xffff00)
$e = _GUICtrlCreateColorButton("test5", 245, 5, 50, 20, 0xffffff)
$f = _GUICtrlCreateColorButton("test6",   5, 35, 50, 20,0xffaa00)
$g = _GUICtrlCreateColorButton("test7",  65, 35, 50, 20,0xaaff00)
$h = _GUICtrlCreateColorButton("test8", 125, 35, 50, 20,0x00aaff,0xffffff)
$i = _GUICtrlCreateColorButton("test9", 185, 35, 50, 20,0xffffaa)
$j = _GUICtrlCreateColorButton("test10",245, 35, 50, 20,0xdddddd)
$k = _GUICtrlCreateColorButton("test11",  5, 65, 50, 20,0xffee00)
$l = _GUICtrlCreateColorButton("test12", 65, 65, 50, 20,0xccff00)
$m = _GUICtrlCreateColorButton("test13",125, 65, 50, 20,0x00ddff,0xffffff)
$n = _GUICtrlCreateColorButton("test14",185, 65, 50, 20,0xffeedd)
$o = _GUICtrlCreateColorButton("test15",245, 65, 50, 20,0x000000,0xffffff)
GUISetState ()

do
   $msg = GUIGetMsg()
    if $msg = $a[0] then msgbox(0, "colorbutton pressed","You pressed cb1",1)
    if $msg = $b[0] then msgbox(0, "colorbutton pressed","You pressed cb2",1)
    if $msg = $c[0] then msgbox(0, "colorbutton pressed","You pressed cb3",1)
    if $msg = $d[0] then msgbox(0, "colorbutton pressed","You pressed cb4",1)
    if $msg = $e[0] then msgbox(0, "colorbutton pressed","You pressed cb5",1)
    if $msg = $f[0] then msgbox(0, "colorbutton pressed","You pressed cb6",1)
    if $msg = $g[0] then msgbox(0, "colorbutton pressed","You pressed cb7",1)
    if $msg = $h[0] then msgbox(0, "colorbutton pressed","You pressed cb8",1)
    if $msg = $i[0] then msgbox(0, "colorbutton pressed","You pressed cb9",1)
    if $msg = $j[0] then msgbox(0,"colorbutton pressed","You pressed cb10",1)
    if $msg = $k[0] then msgbox(0,"colorbutton pressed","You pressed cb11",1)
    if $msg = $l[0] then msgbox(0,"colorbutton pressed","You pressed cb12",1)
    if $msg = $m[0] then msgbox(0,"colorbutton pressed","You pressed cb13",1)
    if $msg = $n[0] then msgbox(0,"colorbutton pressed","You pressed cb14",1)
    if $msg = $o[0] then msgbox(0,"colorbutton pressed","You pressed cb15",1)
until $msg = $GUI_EVENT_CLOSE

;#include-once
;=============================================================================
;
; Function Name:   _GUICtrlCreateColorButton()
;
; Description:   Creates a colored Button
;
; Syntax:         _GUICtrlCreateColorButton($text, $left, $top, $width, $height,$bkcolor[,$fontcolor])
;
; Parameter(s);     $text = The text of the control
;                   $left = The left side of the control
;                   $top = The top of the control
;                   $width = The width of the control
;                   $height = The height of the control
;                   $bkcolor = Backgroundcolor of the control
;                   $fontcolor = [optional] Fontcolor of the control
;
; Return Value(s):  array[1] = used to change colors
;                   array[0] = notifies GUIGetMsg if user clicks
;
; Author:           rakudave <rakudave@gmx.net>
;=============================================================================


Func _GUICtrlCreateColorButton($text, $left, $top, $width, $height,$bkcolor,$fontcolor = 0x000000)
local $colbut[2]
$colbut[0] = GUICtrlCreateLabel("",$left,$top,$width,$height,$SS_BLACKRECT)
GUICtrlCreateLabel("",$left,$top,$width -1,$height -1,$SS_WHITERECT)
GUICtrlCreateLabel("",$left +1,$top +1,$width -2,$height -2,$SS_GRAYRECT)
$colbut[1] = GUICtrlCreateLabel($text,$left +1,$top + 1,$width -3,$height -3,$SS_NOTIFY & $SS_CENTER)
GUICtrlSetBkColor(-1,$bkcolor)
GUICtrlSetColor(-1,$fontcolor)
Return $colbut
EndFunc

What I want to do is replace variables ($a, $b, $c . . . $m, $n, $o) with an array, like $Key[16], so I can put it in a loop.

But I don't know how to get the GUIGetMsg() to work once I do that.

Any help with this is appreciated.

taurus905

Edited: Just noticed I posted in the wrong forum. I will learn how to do this right.

Edited by taurus905

"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Link to comment
Share on other sites

There has to be a different way, those aren't even buttons, there labels

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Link to comment
Share on other sites

I don't care that they're labels(for now). That code is much easier to work with. Thanks a bunch rakudave.

How about starting your own thread on using labels as buttons.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

  • Moderators

yeah in another thread.

Damn Gary, you were hijacked lol :think:

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Ill call the police...

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Link to comment
Share on other sites

Ill call the police...

what happend? what did I miss? You were hacked?

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

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