Jump to content
Sign in to follow this  
kjpolker

Opacity slider

Recommended Posts

kjpolker

Ok so I gave my GUI a slider bar and my first problem I ran into was that my GUI is a black window but I see the slider shows up as an ugly white box in the GUI, I tried changing the color but it didn't seem to do anything, my next problem was how I can read the slider value and make that the opacity, I mean if know how I would do it I just can't seem to figure out the actual wording for it. If someone can help me with these two problems I would appreciate it. This is the only user friendly idea that came to mind for opacity but maybe someone else likes a different way to do this they could share with me on changing opacity. Thanks!

I assumed this would be a pretty common question but I couldn't find anything, not even with google.

Edited by kjpolker

Share this post


Link to post
Share on other sites
BrettF
kjpolker

Yeah so its not a white square, can I not make the slider white with the background of the slider black?

And when I added this line

WinSetTrans("[CLASS:Autoit v3 GUI]", "", GUICtrlRead($Slider1))

It didn't change the transperancy of the window, is there a command to set the value of the slider? as of now I am just using the actual slider variable that made the GUI

$slider1 = GUICtrlCreateSlider(250, 5, 100, 20)
Edited by kjpolker

Share this post


Link to post
Share on other sites
CodyBarrett

guictrlread ()

winsettrans ()

edit : AH!! brett beat me to it

Edited by CodyBarrett

Share this post


Link to post
Share on other sites
kjpolker

I still need help lol, how do I determine the value of the slider?

in the help file under GUICtrlSetData() it just says "For slider: value" and I don't know what that means,

GUICtrlSetData($slider1, 'value')

That wont work.

And how do I make the slider a little more bolder and clearer ad make the background of the slider the color of my GUI window and not white?

Edited by kjpolker

Share this post


Link to post
Share on other sites
CodyBarrett

guictrlsetlimit?

Share this post


Link to post
Share on other sites
kjpolker

Well I just realized that the GUICtrlSetData($slider1, 100) makes the pin on the slider start at 100 which is perfect, now for the actual transperancy your saying all I do is:

$opacity = GUICtrlSetLimit(-1, 100, 0)

WinSetTrans("[CLASS:Autoit v3 GUI]", "", GUICtrlRead($opacity))

Will work?

Share this post


Link to post
Share on other sites
CodyBarrett

should... as long as the return value < 256.... like from 0 - 255 transparency

Share this post


Link to post
Share on other sites
kjpolker

So far I am having no luck with that, I have no idea what I am doing wrong though since I ahve never seen or done a opacity bar. =/ I mean i can move the slider but absolutely nothing happens to the window

Share this post


Link to post
Share on other sites
CodyBarrett

while 1;YOUR MAIN WHILE LOOP
winsettrans ('[active]','',Guictrlread ($Slider))
sleep (100)
wend

Share this post


Link to post
Share on other sites
ProgAndy

Here is an example :) (Compatible with Beta and Stable)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StructureConstants.au3>
#include <SliderConstants.au3>
#include<Misc.au3>

#region - GUI Create
$hGUI = GUICreate('test')
GUISetBkColor(0)
GUICtrlSetDefBkColor(0)
Global $iSlider = GUICtrlCreateSlider(10, 10, 300, 30)
GUICtrlSetBkColor(-1,0)
GUICtrlSetLimit(-1, 255, 1)
GUICtrlSetData(-1, 255)
GUISetState()
#endregion

Global $giOldTRans
If _VersionCompare(@AutoItVersion, '3.3.1.0') > 0 Then
    Execute('AdlibRegister("_UpdatePos", 100)')
Else
    Execute('AdlibEnable("_UpdatePos", 100)')
EndIf

#region - GUI SelectLoop
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $iSlider
            WinSetTrans($hGUI, "", GUICtrlRead($iSlider))
    EndSelect
WEnd
#endregion

Func _UpdatePos()
    Local $trans = GUICtrlRead($iSlider)
    If $giOldTRans = $trans Then Return
    WinSetTrans($hGUI, "", $trans)
    $giOldTRans = $trans
EndFunc

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites
CodyBarrett

Share this post


Link to post
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
Sign in to follow this  

×