Jump to content

How to make button change colour,hide button and disable button


shamike
 Share

Recommended Posts

here how to make button change colour button,backgorund,hide button and disable button

here the example

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global Const $AC_SRC_ALPHA = 1
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate(-1, 330, 323, 0, 0,$WS_Popup)
GUISetFont(10, 800, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("Green", 8, 8, 153, 49)
GUICtrlSetBkColor(-1, 0x00FF00)
$Button2 = GUICtrlCreateButton("Red", 8, 64, 153, 49)
GUICtrlSetBkColor(-1, 0xFF0000)
$Button3 = GUICtrlCreateButton("Blue", 168, 8, 153, 49)
GUICtrlSetBkColor(-1, 0x0000FF)
$Button4 = GUICtrlCreateButton("Yellow", 168, 64, 153, 49)
GUICtrlSetBkColor(-1, 0xFFFF00)
$Button5 = GUICtrlCreateButton("Purple", 8, 120, 153, 49)
GUICtrlSetBkColor(-1, 0xFF00FF)
$Button6 = GUICtrlCreateButton("Aqua", 168, 120, 153, 49)
GUICtrlSetBkColor(-1, 0x00FFFF)
$Button7 = GUICtrlCreateButton("Exit", 8, 169, 313, 50)
$Button8 = GUICtrlCreateButton("Show", 8, 219, 153, 50)
$Button9 = GUICtrlCreateButton("Hide", 168, 219, 153, 50)
$Button10 = GUICtrlCreateButton("Enable", 8, 269, 153, 50)
$Button11 = GUICtrlCreateButton("Disable", 168, 269, 153, 50)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Form1
Case $Form1
Case $Form1
Case $Form1
Case $Button1
GUISetBkColor(0x00FF00);Set $form1 background colour
GUICtrlSetBkColor($Button7,0x00FF00);Set button colour
Case $Button2
GUISetBkColor(0xFF0000)
GUICtrlSetBkColor($Button7,0xFF0000)
Case $Button3
GUISetBkColor(0x0000FF)
GUICtrlSetBkColor($Button7,0x0000FF)
Case $Button4
GUISetBkColor(0xFFFF00)
GUICtrlSetBkColor($Button7,0xFFFF00)
Case $Button5
GUISetBkColor(0xFF00FF)
GUICtrlSetBkColor($Button7,0xFF00FF)
Case $Button6
GUISetBkColor(0x00FFFF)
GUICtrlSetBkColor($Button7,0x00FFFF)
Case $Button7
Exit
Case $Button8
GUICtrlSetState($Button7,$GUI_SHOW);Show button
Case $Button9
GUICtrlSetState($Button7,$GUI_Hide);Hide button
Case $Button10
GUICtrlSetState($Button7,$GUI_ENABLE);Enable button
Case $Button11
GUICtrlSetState($Button7,$GUI_DISABLE);Disable button
EndSwitch
WEnd

to change the background background you need to use this code

GUISetBkColor()

to change the button colour you need

GUICtrlSetBkColor($Button7,0x00FFFF)

for show and hide button

GUICtrlSetState(Control id,$GUI_SHOW);Show button
GUICtrlSetState(Control id,$GUI_HIDE);Hide button

for enable and disable button you need

GUICtrlSetState(Control id,$GUI_ENABLE);Enable button
GUICtrlSetState(Control id,$GUI_DISABLE);Disable button
Link to comment
Share on other sites

  • Moderators

shamike,

Thank you for posting this small tutorial. But I would like to point out that this section of the forum is normally used for more complex AutoIt scripts, rather than explaining what can easily be found in the Help file. ;)

If you want to add more tutorials at the same level in the future, then please add them to this thread and do not start a new thread for each one. I will change the title if you wish - perhaps "shamike's tutorials" would be a good idea. :)

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

shamike,

Thank you for posting this small tutorial. But I would like to point out that this section of the forum is normally used for more complex AutoIt scripts, rather than explaining what can easily be found in the Help file. ;)

If you want to add more tutorials at the same level in the future, then please add them to this thread and do not start a new thread for each one. I will change the title if you wish - perhaps "shamike's tutorials" would be a good idea. :)

M23

ok i will do it
Link to comment
Share on other sites

  • Moderators

shamike,

Thanks. :thumbsup:

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

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