Jump to content

Make a blue gradient colored gui background


LostUser
 Share

Recommended Posts

Hi all. Long time no posty.

Not sure if the topic title is right but here is what I am trying to do. I've been searching the forums but haven't got quite the right answer yet.

You know those install screens where the background of the gui window is shaded from dark blue at the top to a lighter blue at the bottom?

That is what I want to try and do.

I am converting our SMS installer scripts and would like to keep this feature as it is a familiar site when doing installs. Of course, I like to change the gradient colors but starting out with the classic blue would be nice.

I don't have any script code to show because, frankly, I haven't been able to replicate this.

Here is my basic Gui creation code however.

$W_STARINSTALL = GUICreate("Star Navigator Install",@DesktopWidth-10,@DesktopHeight-30,0,0)
GUICtrlCreatePic($NETDIR & "STAR Navigator Upgrade.bmp",@DesktopWidth/2-150,1,300,178)
GUISetState(@SW_SHOW,$W_STARINSTALL)

Appreciate any help I can get with this.

Be open minded but not gullible.A hammer sees everything as a nail ... so don't be A tool ... be many tools.

Link to comment
Share on other sites

I know this is slightly off in regards to the question (I'm sure a gradient bg can be done in Autoit) but still; why not use NSIS, it is extremely powerful for creating setups/install rutines & its interface is completely standardized..?

Update: I did minimal searching on the forum and found loads of stuff on setting background pictures (..) assuming you can make a gradient picture in photoshop or the like this should very easy to solve, see following threads:

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

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

etc. etc.

Edited by Sunaj
Link to comment
Share on other sites

I was playing about making gradients the other day.

This is my code that may or may not be of any use

#include <GUIConstants.au3>

GUICreate("Test",600,600)


$timer = TimerInit()
GuiCtrlCreateGraphic(0,0,600,600)
GUICtrlSetBkColor(-1,0x000000)
$gradient = 5
For $Y1= 0 to 550 step 50
    For $Y2 = 0 to 49
        Switch $Y2
            case 2 to 24
                $color = 255-24*$gradient+$y2*$gradient
                ConsoleWrite($color&@crlf)
                GUICtrlSetGraphic(-1,$GUI_GR_COLOR,$color,$color)
                GUICtrlSetGraphic(-1,$GUI_GR_MOVE, 0,$y1+$y2)
                GUICtrlSetGraphic(-1,$GUI_GR_LINE, 600,$y1+$y2)
            Case 25 to 47
                $color = 255+25*$gradient-($y2*$gradient)
                ConsoleWrite($color&@crlf)
                GUICtrlSetGraphic(-1,$GUI_GR_COLOR,$color,$color)
                GUICtrlSetGraphic(-1,$GUI_GR_MOVE, 0,$y1+$y2)
                GUICtrlSetGraphic(-1,$GUI_GR_LINE, 600,$y1+$y2)
        EndSwitch   
    Next

Next
GuiSetState()
ConsoleWrite(TimerDiff($timer))

Do
    $msg = GUIGetMsg()
Until $msg=$GUI_EVENT_CLOSE
My Scripts[topic="73325"]_ReverseDNS()[/topic]Favourite scripts by other members[topic="81687"]SNMP udf[/topic][topic="70759"]Using SNMP - MIB protocol[/topic][topic="39050"]_SplitMon:Section off your monitor!, split your monitor into sections for easy management[/topic][topic="73425"]ZIP.au3 UDF in pure AutoIt[/topic][topic="10534"]WMI ScriptOMatic tool for AutoIt[/topic][topic="51103"]Resources UDF embed/use any data/files into/from AutoIt compiled EXE files[/topic]
Link to comment
Share on other sites

Seriously, that is a very nice color drawing rutine you made! Reminds me of oldskool Amiga 500 demos :whistle:

Sunaj

I was playing about making gradients the other day.

This is my code that may or may not be of any use

#include <GUIConstants.au3>

GUICreate("Test",600,600)


$timer = TimerInit()
GuiCtrlCreateGraphic(0,0,600,600)
GUICtrlSetBkColor(-1,0x000000)
$gradient = 5
For $Y1= 0 to 550 step 50
    For $Y2 = 0 to 49
        Switch $Y2
            case 2 to 24
                $color = 255-24*$gradient+$y2*$gradient
                ConsoleWrite($color&@crlf)
                GUICtrlSetGraphic(-1,$GUI_GR_COLOR,$color,$color)
                GUICtrlSetGraphic(-1,$GUI_GR_MOVE, 0,$y1+$y2)
                GUICtrlSetGraphic(-1,$GUI_GR_LINE, 600,$y1+$y2)
            Case 25 to 47
                $color = 255+25*$gradient-($y2*$gradient)
                ConsoleWrite($color&@crlf)
                GUICtrlSetGraphic(-1,$GUI_GR_COLOR,$color,$color)
                GUICtrlSetGraphic(-1,$GUI_GR_MOVE, 0,$y1+$y2)
                GUICtrlSetGraphic(-1,$GUI_GR_LINE, 600,$y1+$y2)
        EndSwitch   
    Next

Next
GuiSetState()
ConsoleWrite(TimerDiff($timer))

Do
    $msg = GUIGetMsg()
Until $msg=$GUI_EVENT_CLOSE
Link to comment
Share on other sites

Thanks rogdog, that helps. It seems to have what I would need to get what I want.

I'll mess around with the gui control commands and post back here to show what I mean.

Will probably have to wait until tomorrow.

Thanks again.

Sunaj. Why use AutoIt rather than NSIS? I suppose since I have been moving from SMS installer to AutoIt is one reason. AutoIt has some big plusses that SMS either didn't have or required some work-arounds to do.

Also, I don't know anything about NSIS and I have some jobs I need to do soon to keep things going. I don't have time to learn something else...also I like AutoIt...it is my friend right now.

Heh.

Be open minded but not gullible.A hammer sees everything as a nail ... so don't be A tool ... be many tools.

Link to comment
Share on other sites

Seriously, that is a very nice color drawing rutine you made! Reminds me of oldskool Amiga 500 demos :whistle:

Sunaj

hehehe , those were the days, I had loads of amiga demo disks. Don't know what purpose they served but the kept me occupied for a looooong time :P

My Scripts[topic="73325"]_ReverseDNS()[/topic]Favourite scripts by other members[topic="81687"]SNMP udf[/topic][topic="70759"]Using SNMP - MIB protocol[/topic][topic="39050"]_SplitMon:Section off your monitor!, split your monitor into sections for easy management[/topic][topic="73425"]ZIP.au3 UDF in pure AutoIt[/topic][topic="10534"]WMI ScriptOMatic tool for AutoIt[/topic][topic="51103"]Resources UDF embed/use any data/files into/from AutoIt compiled EXE files[/topic]
Link to comment
Share on other sites

I know this is slightly off in regards to the question (I'm sure a gradient bg can be done in Autoit) but still; why not use NSIS, it is extremely powerful for creating setups/install rutines & its interface is completely standardized..?

I recently used NSIS for the first time about a month ago. I was very impressed with its capabilities although I still ended up including a compiled autoit file into the install package as the NSIS language was not capable of what I needed.

My Scripts[topic="73325"]_ReverseDNS()[/topic]Favourite scripts by other members[topic="81687"]SNMP udf[/topic][topic="70759"]Using SNMP - MIB protocol[/topic][topic="39050"]_SplitMon:Section off your monitor!, split your monitor into sections for easy management[/topic][topic="73425"]ZIP.au3 UDF in pure AutoIt[/topic][topic="10534"]WMI ScriptOMatic tool for AutoIt[/topic][topic="51103"]Resources UDF embed/use any data/files into/from AutoIt compiled EXE files[/topic]
Link to comment
Share on other sites

Maybe..

#include-once
#include <Color.au3>
#include <GUIConstants.au3>


$gui = GUICreate("Gradient")
$Back_Color = XSkinGradient($gui, 0x8080ff , 0x80800f); $btn_color, $bkg_color)
GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = -3 Then Exit
Wend



Func XSkinGradient($nXSkinGUI, $nStartColor, $nEndColor)
    Local $nSize = WinGetClientSize($nXSkinGUI)
    Local $nX=0, $nY=0, $nWidth=$nSize[0], $nHeight=$nSize[1]
    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
    $nGraph = GuiCtrlCreateGraphic($nX, $nY, $nWidth, $nHeight)
    For $i = 0 To $nHeight - $nY
        $sColor = "0x" & StringFormat("%02X%02X%02X", $color1R+$nStepR*$i, $color1G+$nStepG*$i, $color1B+$nStepB*$i)
        GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $sColor, 0xffffff)
        GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 0, $i)
        GUICtrlSetGraphic(-1, $GUI_GR_LINE, $nWidth, $i)
    Next
    GUICtrlSetState( $nGraph, $GUI_DISABLE)
    Return $nGraph
EndFunc

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

If you search the Example Scripts forum for "Gradient" there is a Gradient script (with examples) that works well. It might even be the ame one that @Valuater just posted.

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

If you search the Example Scripts forum for "Gradient" there is a Gradient script (with examples) that works well. It might even be the ame one that @Valuater just posted.

Yes thats true... Mine is an extention of a script I found, and actually i state in the post

"Thanks to Zedna, gafrost, and CoePSX"

heres the thread

http://www.autoitscript.com/forum/index.ph...st&p=295613

8)

NEWHeader1.png

Link to comment
Share on other sites

Thanks rogdog, that helps. It seems to have what I would need to get what I want.

I'll mess around with the gui control commands and post back here to show what I mean.

Will probably have to wait until tomorrow.

Thanks again.

Sunaj. Why use AutoIt rather than NSIS? I suppose since I have been moving from SMS installer to AutoIt is one reason. AutoIt has some big plusses that SMS either didn't have or required some work-arounds to do.

Also, I don't know anything about NSIS and I have some jobs I need to do soon to keep things going. I don't have time to learn something else...also I like AutoIt...it is my friend right now.

Heh.

If you don't like NSIS then try Inno Setup. It's extremly simple to script and you could even use AutoIt to create the script for you.

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

Yes thats true... Mine is an extention of a script I found, and actually i state in the post

"Thanks to Zedna, gafrost, and CoePSX"

heres the thread

http://www.autoitscript.com/forum/index.ph...st&p=295613

8)

I knew that part of your code looked familiar I already have that script but like so many others it's been archived and I didn't feel like going to the other system to do a CD search looking for it.

Just getting too lazy I guess.

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

hehehe , those were the days, I had loads of amiga demo disks. Don't know what purpose they served but the kept me occupied for a looooong time :whistle:

I used to have an Amiga 500. I still have an Amiga 3000 under my desk in my office (I couldn't justify its existence at home to my other anymore). I also have some things on there I would one day like to move/port over to my Windows PC.

All:Thanks for your help. I see I need to mess around with GUICtrlSetGraphic, GUICtrlCreateGraphic, and GUICtrlSetState commands. Also, that StringFormat command looks interesting too.

It will take me a little time to understand how those scripts and how those commands are working. Sometimes it takes time for something to sink in until I finally get that...Hey! That's how it works!...revelation to come to me.

Valuater, that one works exactly like I would like it to. I may try to keep my includes down though (color.au3). It looks like that just allows you to split the colors into rgb and use those values to get the shading. Of course, once the script is compiled it doesn't matter. The reason is that other people may be changing the script when updates for the software are made and I want to have as little chance for error as possible. It is only cosmetic but it makes things look a little nicer and more familiar.

Be open minded but not gullible.A hammer sees everything as a nail ... so don't be A tool ... be many tools.

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