Jump to content

Recommended Posts

Posted (edited)

This is script which I'm trying to modify to work on all XP themes, it work fine on my comp with xp theme but on classic theme gradient is not visible. I don't undersand C++, this is CGradientStatic source CGradientStatic.rarwhich change the gradient color depending on GetSysColor(COLOR_BTNFACE) - maybe someone can help me to make this one working in au.3

_My BTNFACE _ Gradient Color

#include "GUIConstants.au3"
#include <Color.au3>

$out = DllCall("user32", "long", "GetSysColor", "long", 15)

$hColor = Hex($out[0], 6)
$hexColor = StringRight($hColor, 2) & StringMid($hColor, 3, 2) & StringLeft($hColor, 2)

GUICreate("Gradient", 120, 120)
_GUICreateGradient("***", "0x" & $hexColor, 10, 10, 100, 100); "***" to be changed depending on color scheme

GUISetState()

Do
    $msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE

Func _GUICreateGradient($nStartColor, $nEndColor, $nX, $nY, $nWidth, $nHeight)
    Local $color1R = _ColorGetRed($nStartColor)
    Local $color1G = _ColorGetGreen($nStartColor)
    Local $color1B = _ColorGetBlue($nStartColor)
    
    Local $nStepR = (_ColorGetRed($nEndColor) - $color1R) / $nHeight
    Local $nStepG = (_ColorGetGreen($nEndColor) - $color1G) / $nHeight
    Local $nStepB = (_ColorGetBlue($nEndColor) - $color1B) / $nHeight
    For $i = 0 To $nHeight
        $sColor = "0x" & StringFormat("%02X%02X%02X", $color1R + $nStepR * $i, $color1G + $nStepG * $i, $color1B + $nStepB * $i)
        $label = GUICtrlCreateLabel("", $nX, $nY + $i, $nWidth, 1)
        GUICtrlSetBkColor($label, $sColor)
    Next
EndFunc

EDIT: Changed pic. location

Edited by eJan
Posted

Not sure what your saying/asking

Here's the results of $out[0]

I added #include <Misc.au3>

and then called _ChooseColor(0,$out[0]) right after the dllcall for GetSysColor

Classic

http://www.autoitscript.com/fileman/users/gafrost/Classic.JPG

XP Theme

http://www.autoitscript.com/fileman/users/gafrost/XPTheme.JPG

SciTE for AutoItDirections for Submitting Standard UDFs

 

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

 

Posted (edited)

Not sure what your saying/asking

Actually I need math calculation to set gradient color darken than windows theme (button face).

Where in XP style button face = 236, 233, 216 and gradient color = 198, 198, 188

__ In classic style button face = 212, 208, 199 and gradient color = 178, 177, 173

_GUICreateGradient("***", "0x" & $hexColor, 10, 10, 100, 100)

In my case i need help to set math calculation for "***" to set gradient darken than color scheme.

In first topic i've added picture to show differencies between button face and gradient color - where gradient color (cross) in color scheme is "moved" only vertically and all R, G, B values are changed. Maybe the solution is in _ColorGetRed, G, B but I don't know which color scheme users have ..maybe olive, green or ...

COLORREF DarkenColor(COLORREF col,double factor)
{
    if(factor>0.0&&factor<=1.0){
        BYTE red,green,blue,lightred,lightgreen,lightblue;
        red = GetRValue(col);
        green = GetGValue(col);
        blue = GetBValue(col);
        lightred = (BYTE)(red-(factor*red));
        lightgreen = (BYTE)(green-(factor*green));
        lightblue = (BYTE)(blue-(factor*blue));
        col = RGB(lightred,lightgreen,lightblue);
    }
    return(col);
}

I have added pics of same app in different color schemes:

This is "***" gradient which I try to make it working with au3

EDIT: changed pic. location

Edited by eJan
  • Moderators
Posted

Just a note... You might want to change where you are showing these files, there are "Kids" that use AutoIt, and the banners (Although not hurtful to the adult eye :o ) do not seem suitable for kids. Maybe just upload them?

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.

Posted (edited)

Not sure how accurate this is:

#include "GUIConstants.au3"
#include <Color.au3>


$out = DllCall("user32", "long", "GetSysColor", "long", 15)

$hColor = Hex($out[0], 6)
$hexColor = StringRight($hColor, 2) & StringMid($hColor, 3, 2) & StringLeft($hColor, 2)
$hexColor_S = Hex(Asc(StringRight($hColor, 2)) + 130, 2) & Hex(Asc(StringMid($hColor, 3, 2)) + 130, 2) & Hex(Asc(StringLeft($hColor, 2)) + 121, 2)
GUICreate("Gradient", 120, 120)
_GUICreateGradient("0x" & $hexColor_S, "0x" & $hexColor, 10, 10, 100, 100); "***" to be changed depending on color scheme

GUISetState()

Do
    $msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE

Func _GUICreateGradient($nStartColor, $nEndColor, $nX, $nY, $nWidth, $nHeight)
    Local $color1R = _ColorGetRed($nStartColor)
    Local $color1G = _ColorGetGreen($nStartColor)
    Local $color1B = _ColorGetBlue($nStartColor)
    
    Local $nStepR = (_ColorGetRed($nEndColor) - $color1R) / $nHeight
    Local $nStepG = (_ColorGetGreen($nEndColor) - $color1G) / $nHeight
    Local $nStepB = (_ColorGetBlue($nEndColor) - $color1B) / $nHeight
    For $i = 0 To $nHeight
        $sColor = "0x" & StringFormat("%02X%02X%02X", $color1R + $nStepR * $i, $color1G + $nStepG * $i, $color1B + $nStepB * $i)
        $label = GUICtrlCreateLabel("", $nX, $nY + $i, $nWidth, 1)
        GUICtrlSetBkColor($label, $sColor)
    Next
EndFunc  ;==>_GUICreateGradient
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.

 

Posted

Thanks gafrost for interesting solution, I was thinking: it can be done, but C++ is more complex, I will add If statement for XP scheme Else for other schemes and thats O.K.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...