Jump to content



Photo

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


  • Please log in to reply
4 replies to this topic

#1 shamike

shamike

    Seeker

  • Normal Members
  • 4 posts

Posted 04 August 2012 - 09:30 AM

here how to make button change colour button,backgorund,hide button and disable button
here the example
Plain Text         
#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






#2 Melba23

Melba23

    Yes, me!

  • Moderators
  • 15,374 posts

Posted 04 August 2012 - 09:44 AM

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
StringSize - Automatically size controls to fit text - ExtMsgBox - A user customisable replacement for MsgBox

Toast - Small GUIs which pop out of the Systray - Marquee - Scrolling tickertape GUIs

Scrollbars - Automatically sized scrollbars with a single command - GUIFrame - Subdivide GUIs into many adjustable frames

GUIExtender - Extend and retract multiple sections within a GUI - NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes

ChooseFileFolder - Single and multiple selections from specified path tree structure - - Notify - Small notifications on the edge of the display

RecFileListToArray - An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options

GUIListViewEx - Insert, delete, move, drag and sort ListView items


#3 squidol

squidol

    Seeker

  • Active Members
  • 7 posts

Posted 04 August 2012 - 12:19 PM

thanks for the tutorial, try using koda gui designer, it will help you design your gui at ease.

#4 shamike

shamike

    Seeker

  • Normal Members
  • 4 posts

Posted 08 August 2012 - 08:55 AM

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

#5 Melba23

Melba23

    Yes, me!

  • Moderators
  • 15,374 posts

Posted 08 August 2012 - 04:02 PM

shamike,

Thanks. :thumbsup:

M23
StringSize - Automatically size controls to fit text - ExtMsgBox - A user customisable replacement for MsgBox

Toast - Small GUIs which pop out of the Systray - Marquee - Scrolling tickertape GUIs

Scrollbars - Automatically sized scrollbars with a single command - GUIFrame - Subdivide GUIs into many adjustable frames

GUIExtender - Extend and retract multiple sections within a GUI - NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes

ChooseFileFolder - Single and multiple selections from specified path tree structure - - Notify - Small notifications on the edge of the display

RecFileListToArray - An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options

GUIListViewEx - Insert, delete, move, drag and sort ListView items





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users