GUI GetSet Prop Example Colour
From Sputnik Wiki
(Difference between revisions)
(Created page with "<pre> Change colour of controls </pre> === Description === This example demonstrates how to change the Background and Foreground(Usuaully text) on buttons and windows. === Rem...") |
(→Example) |
||
Line 63: | Line 63: | ||
println("Button 2 ForeColour $HexB2"); | println("Button 2 ForeColour $HexB2"); | ||
println("Button 3 ForeColour $HexB2"); | println("Button 3 ForeColour $HexB2"); | ||
− | |||
− | |||
− | |||
− | |||
− | |||
// Loop while GUI is active | // Loop while GUI is active |
Revision as of 12:19, 2 December 2011
Change colour of controls
Description
This example demonstrates how to change the Background and Foreground(Usuaully text) on buttons and windows.
Remarks
Colour values are R G B example 0xFF0000; Is RED 0x00FF00; Is GREEN 0x0000FF; Is BLUE
You can change the colours on just about every single control.
Example
// Create a new GUI Glob $GUI = GUICreate("GUI", 640, 480); GUISetState($GUI, @Show); // Make tab $obj_TAB = GUICreateTabSheet($GUI, "textbox", 5, 15, 610, 370); // Add pages $TabPage1 = GUITabSheet($obj_TAB, "AddTab", "Moo", "Testy Tab1"); $TabPage2 = GUITabSheet($obj_TAB, "AddTab", "Cat", "Testy Tab2"); $TabPage3 = GUITabSheet($obj_TAB, "AddTab", "Dog", "Testy Tab3"); // Add buttons $T1_Button1 = GUICreateButton($TabPage1, "t1b1", "My Button Tab1", 8, 8); $T2_Button1 = GUICreateButton($TabPage2, "t2b1", "My Button Tab2", 8, 48); $T3_Button1 = GUICreateButton($TabPage3, "t3b1", "My Button Tab3", 48, 38); // Change the main window to Yellow GUISetProp($GUI, "BackColor", 0xFFFF00); // Make it Yellow println("Main Window BackColour" . Hex(GUIGetProp($GUI, "BackColor"))); // Print the colour // Change the button background colours GUISetProp($T1_Button1, "BackColor", 0xFF0000); // Make it Red GUISetProp($T2_Button1, "BackColor", 0x0000FF); // Make it Blue GUISetProp($T3_Button1, "BackColor", 0x00FF00); // Make it Green // Get the hex of the colours so we could use it somewhere else $HexB1 = Hex(GUIGetProp($T1_Button1, "BackColor")); $HexB2 = Hex(GUIGetProp($T2_Button1, "BackColor")); $HexB3 = Hex(GUIGetProp($T3_Button1, "BackColor")); // Print the hex println("Button 1 BackColour $HexB1"); println("Button 2 BackColour $HexB2"); println("Button 3 BackColour $HexB2"); // Change the button foreground (Text) colours GUISetProp($T1_Button1, "ForeColor", 0x00FF00); // Make it Green GUISetProp($T2_Button1, "ForeColor", 0xFF0000); // Make it Red GUISetProp($T3_Button1, "ForeColor", 0x0000FF); // Make it Blue // Get the hex of the colours so we could use it somewhere else $HexB1 = Hex(GUIGetProp($T1_Button1, "ForeColor")); $HexB2 = Hex(GUIGetProp($T2_Button1, "ForeColor")); $HexB3 = Hex(GUIGetProp($T3_Button1, "ForeColor")); // Print the hex println("Button 1 ForeColour $HexB1"); println("Button 2 ForeColour $HexB2"); println("Button 3 ForeColour $HexB2"); // Loop while GUI is active Until ( GUIState( $GUI ) == @sClosed ) { DoEvents(); // DoEvents to keep the GUI working fine }