Jump to content

Set menu color?


Recommended Posts

I can help you with an example of progress bar with color:

Global $PROGRESS,$LABEL

$GUI = GUICreate("Example")
$PROGRESS = ProgressBar_Create($GUI,100,100,200,20,0x00B400,0x008000)
$LABEL = GUICtrlCreateLabel("",150,130,100,20,BitOR(0x01,0x1000))
GUISetState(@SW_SHOW,$GUI)

AdlibRegister("UpdateProgress",1500)

While True
    Switch GUIGetMsg()
        Case -3
            ProgressBar_Destroy($PROGRESS)
            AdlibUnRegister("UpdateProgress")
            Exit
    EndSwitch
    Sleep(10)
WEnd

Func UpdateProgress()
    $RND = Round(Random(0,100),2)
    ProgressBar_SetPercent($PROGRESS,$RND)
    GUICtrlSetData($LABEL,ProgressBar_GetPercent($PROGRESS))
EndFunc

Func ProgressBar_Create($GUI,$X,$Y,$W,$H,$COLOR,$BKCOLOR)
    Local $CTRL[9]
    $CTRL[0] = GUICtrlCreateLabel("",$X,$Y,$W,$H)
    $CTRL[1] = GUICtrlCreateLabel("",$X+1,$Y+1,1,$H-2)
    $CTRL[2] = $X+1
    $CTRL[3] = $Y+1
    $CTRL[4] = $W-2
    $CTRL[5] = $H-2
    $CTRL[6] = 0
    $CTRL[7] = False
    $CTRL[8] = $GUI
    GUICtrlSetResizing($CTRL[0],802)
    GUICtrlSetResizing($CTRL[1],802)
    GUICtrlSetBkColor($CTRL[0],$BKCOLOR)
    GUICtrlSetBkColor($CTRL[1],$COLOR)
    ControlDisable($GUI,"",$CTRL[0])
    ControlHide($GUI,"",$CTRL[1])
    Return $CTRL
EndFunc

Func ProgressBar_SetPercent(ByRef $CTRL,$PERCENT)
    If IsArray($CTRL) Then
        If UBound($CTRL) = 9 Then
            If $PERCENT < 0 Then $PERCENT = 0
            If $PERCENT > 100 Then $PERCENT = 100
            If $PERCENT = 0 Then
                If $CTRL[7] Then
                    ControlHide($CTRL[8],"",$CTRL[1])
                    $CTRL[7] = False
                EndIf
            Else
                Local $POS = $CTRL[4]*$PERCENT/100
                GUICtrlSetPos($CTRL[1],$CTRL[2],$CTRL[3],$POS,$CTRL[5])
                If Not $CTRL[7] Then ControlShow($CTRL[8],"",$CTRL[1])
                $CTRL[7] = True
            EndIf
            $CTRL[6] = $PERCENT
        EndIf
    EndIf
EndFunc

Func ProgressBar_GetPercent($CTRL)
    If IsArray($CTRL) Then
        If UBound($CTRL) = 9 Then
            Return $CTRL[6]
        EndIf
    EndIf
EndFunc

Func ProgressBar_Destroy(ByRef $CTRL)
    If IsArray($CTRL) Then
        If UBound($CTRL) = 9 Then
            GUICtrlDelete($CTRL[0])
            GUICtrlDelete($CTRL[1])
            $CTRL = 0
        EndIf
    EndIf
EndFunc
Edited by Andreik

When the words fail... music speaks.

Link to comment
Share on other sites

For menus try this one

http://www.autoitscript.com/forum/index.php?showtopic=20967

The ModernMenuRaw.au3 file is outdated and requires a fix. James Brooks has posted that part here.

His code block is currently messed up and you can either sort that out or PM me and I'll send a version that I fixed to work with the current version of AutoIt.

Another one you might be interested in is

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Hello, is there a way to set the menu and progress bar colors? If you only know the menu one I'd be thankful =D. -Donald8282

The helpfile give you a hint on how to color Progressbars

Checkbox, Radio, Group or Progress controls cannot be painted if the "Windows XP/Vista style" is used.

So you can disable the theme with SetWindowTheme to have it colored, example:

GUICreate(@ScriptName, 640, 480)
GUISetState()

$h1 = GUICtrlCreateProgress(5, 5, 500, 50)
GUICtrlSetColor(-1, 0xFF0000)   ;Red
$h2 = GUICtrlCreateProgress(5, 100, 500, 50)
GUICtrlSetColor(-1, 0xFF0000)   ;Red
$hDisable = GUICtrlCreateButton("Disable theme", 200, 200, 100, 50)
$hEnable = GUICtrlCreateButton("Enable theme", 400, 200, 100, 50)

$iTimer = TimerInit()

While 1
    Do
        $iMsg = GUIGetMsg()
        If $iMsg = -3 Then
            Exit
        ElseIf $iMsg = $hDisable Then
            DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($h2), "ptr", 0, "wstr", "")
        ElseIf $iMsg = $hEnable Then
            DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($h2), "ptr", 0, "ptr", 0)
        EndIf
    Until $iMsg = 0

    If TimerDiff($iTimer) > 500 Then
        GUICtrlSetData($h1, Random(0, 100, 1))
        GUICtrlSetData($h2, Random(0, 100, 1))
        $iTimer = TimerInit()
    EndIf
WEnd
Link to comment
Share on other sites

or draw your own and color them whatever you like

$xpos = 100
$ypos = 100

While 1

ProgressOn("Manual Progress", "Drawing your own...", "0 percent" , $xpos , $ypos , 1)

$R = 0
$Rcolor = random (0x000000 , 0xFFFFFF)

For $P = $xpos + 22 to $xpos + 278 step 2.5
    For $D = $ypos + 32 to $ypos + 48
    _pixelsetcolor ($P , $D , $Rcolor)
    sleep (1)
    If $D = $ypos + 48 Then
        If $R > 99 Then $R = 99
        progressset (0 , $R & ' percent complete')
        $R += 1
        If $R = 90 Then $Rcolor = random (0x000000 , 0xFFFFFF)
        Endif
Next
Next

progressset (0 , '100 percent complete')
sleep (1000)

$R = 0
$Rcolor = random (0x000000 , 0xFFFFFF)

progressset (0 , $R & ' percent complete')

    For $D = $ypos + 32 to $ypos + 48
For $P = $xpos + 22 to $xpos + 278 step 2.5
    _pixelsetcolor ($P , $D , $Rcolor)
    sleep (10)
    If $P > $xpos + 275 Then
        If $R = 0 Then $R = 6
        progressset (0 , $R & ' percent complete')
        If $R > 99 Then $R = 99
        $R += 6
        Endif
Next
Next

progressset (0 , '100 percent complete')
sleep (1000)


    For $P = $xpos + 278 to $xpos + 22 step -1
    For $D = $ypos + 32 to $ypos + 48
    _pixelsetcolor ($P , $D , 0xFFFFFF)
    If $D = $ypos + 48 Then
        If $R < 1 Then $R = 1
        progressset (0 , 'Rolling Back:  ' & $R & ' percent left')
        $R -= .3
        Endif
Next
Next

progressset (0 , '100 percent rolled back')
sleep (1000)

progressoff ()
Wend



; Modified from http://www.autoitscript.com/forum/index.php?showtopic=7315&view=findpost&p=178779
Func _PixelSetColor($XCoord, $YCoord, $Color)
    Local $dc = DllCall("user32.dll", "int", "GetDC", "hwnd", 0)
    If Not IsArray($dc) Then Return -1
    DllCall("gdi32.dll", "long", "SetPixel", "long", $dc[0], "long", $XCoord, "long", $YCoord, "long", _
            "0x" & StringRegExpReplace(hex($Color,6), "(..)(..)(..)", "\3\2\1")) ; Change to 0xBBGGRR hex colour format.
    DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "hwnd", $dc[0])
EndFunc ;==>_PixelSetColor

Func _HPSleep($iSleep, $fMs = 1)
    ; default is milliseconds, otherwise microseconds (1 ms = 1000 µs)
    If $fMs Then $iSleep *= 1000 ; convert to ms
    DllCall("ntdll.dll", "dword", "NtDelayExecution", "int", 0, "int64*", -10 * $iSleep)
EndFunc

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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