Jump to content
Sign in to follow this  
mvk25

Icon and AVI controls losing transparency in status bar

Recommended Posts

mvk25

Hi ;)

I am trying to embed an icon control and an AVI control in the status bar but the problem is they won't retain their transparency.

An example:

#include <GuiStatusBar.au3>
#include <GUIConstantsEx.au3>

Global $WindowMain = GUICreate("Example", 351, 176, -1, -1)
GUISetBkColor( 0xDDDDDD, $WindowMain )
Global $Statusbar = _GUICtrlStatusBar_Create($WindowMain)
Global $Statusbar_PartsWidth[2] = [324, -1]
_GUICtrlStatusBar_SetParts($Statusbar, $Statusbar_PartsWidth)
_GUICtrlStatusBar_SetText($Statusbar, "", 0)
_GUICtrlStatusBar_SetText($Statusbar, "", 1)
_GUICtrlStatusBar_SetMinHeight($Statusbar, 20)
GUISetState(@SW_SHOW)

$Icon = GUICtrlCreateIcon('ico.ico',-1,300,130,16,16) ;Icon on GUI
;Without this the icon will not be tranparent. No idea why.
GUICtrlSetState($icon, $GUI_SHOW)

$Icon2 = GUICtrlCreateIcon('ico.ico',-1,10,10,16,16)
_GUICtrlStatusBar_EmbedControl($Statusbar, 1, GUICtrlGetHandle($Icon2), 1+2)
; This has no effect. Icon has a white square around it
GUICtrlSetState($icon2, $GUI_SHOW)

$AVI = GUICtrlCreateAvi( 'avi.avi',0,250,130,16,16)
GUICtrlSetState( $AVI, 1 )

$AVI2 = GUICtrlCreateAvi( 'avi.avi',0,250,130,16,16)
GUICtrlSetState( $AVI2, 1 )
_GUICtrlStatusBar_EmbedControl($Statusbar, 0, GUICtrlGetHandle($AVI2), 1+2)

Global $GuiMsg
Do
$GuiMsg = GUIGetMsg()
Until $GuiMsg = $GUI_EVENT_CLOSE

I've tried a couple of things like using _GUICtrlStatusBar_SetIcon() or GDIplus for icons and that works and the icons are transparent. As for the AVI, I tried faking a status bar by drawing some lines at the buttom of the window and that worked ok too, But I'd love to be able to use it with a real status bar.

example.zip

Share this post


Link to post
Share on other sites
rover

Welcome to the forums mvk25

A few things to try:

1 - Embedded UDF avi control: AVI Control gets background brush from statusbar (not themed but not as visible as your gui background colour)

2 - Embedded UDF avi control: Turn off themes for the statusbar - (control gets background brush from unthemed statusbar)

3 - Embedded native avi control: Turn off themes for the statusbar and set statusbar colour same as gui (control gets background brush from parent gui)

4 - Embedded native/UDF avi control: Get statusbar theme/system colour* and return brush in _WM_CTLCOLORSTATIC message handler

(udf avi control created with gui as parent, then made parent of statusbar, so we get a WM_CTLCOLORSTATIC message)

;*(issues with getting colour from themed statusbar and themes that have a background gradient in the statusbar - the default xp theme has a gradient themed statusbar)

5 - Embedded native/UDF avi control: write the themed background to a memdc, write to a bitmap and create a brush from it to return in _WM_CTLCOLORSTATIC message handler

(requires code to monitor theme change and create a new brush)

#include <WindowsConstants.au3>
#include <GuiAVI.au3>
#include <GuiStatusBar.au3>
#include <GUIConstantsEx.au3>

_example1()
_example2()
_example3()
Exit

Func _example1()
    Local $WindowMain = GUICreate("Example", 351, 176, -1, -1)
    GUISetBkColor(0xDDDDDD, $WindowMain)
    Local $Statusbar = _GUICtrlStatusBar_Create($WindowMain)
    Local $Statusbar_PartsWidth[2] = [324, -1]
    _GUICtrlStatusBar_SetParts($Statusbar, $Statusbar_PartsWidth)
    _GUICtrlStatusBar_SetText($Statusbar, "", 0)
    _GUICtrlStatusBar_SetText($Statusbar, "", 1)
    _GUICtrlStatusBar_SetMinHeight($Statusbar, 20)
    Local $hIcon = __GUICtrlStatusBar_SetIcon($Statusbar, 1, 0, 'ico.ico') ;the original udf destroys the icon handle
    Local $Icon = GUICtrlCreateIcon('ico.ico', -1, 300, 130, 16, 16) ;Icon on GUI - place before GUISetState
    Local $AVI = GUICtrlCreateAvi('avi.avi', 0, 250, 130, 16, 16)
    GUICtrlSetState($AVI, 1)
    Local $hAVI2 = _GUICtrlAVI_Create($WindowMain, 'avi.avi', -1, 154, 4, 16, 16)
    _GUICtrlStatusBar_EmbedControl($Statusbar, 0, $hAVI2, 1 + 2)
    _GUICtrlAVI_Play($hAVI2)
    GUISetState(@SW_SHOW)
    Local $GuiMsg
    Do
        $GuiMsg = GUIGetMsg()
    Until $GuiMsg = $GUI_EVENT_CLOSE
    _WinAPI_DestroyIcon($hIcon)
    Return
EndFunc   ;==>_example1

Func _example2()
    Local $WindowMain = GUICreate("Example", 351, 176, -1, -1)
    GUISetBkColor(0xDDDDDD, $WindowMain)
    Local $Statusbar = _GUICtrlStatusBar_Create($WindowMain)
    DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", $Statusbar, "wstr", 0, "wstr", 0)
    Local $Statusbar_PartsWidth[2] = [324, -1]
    _GUICtrlStatusBar_SetParts($Statusbar, $Statusbar_PartsWidth)
    _GUICtrlStatusBar_SetText($Statusbar, "", 0)
    _GUICtrlStatusBar_SetText($Statusbar, "", 1)
    _GUICtrlStatusBar_SetMinHeight($Statusbar, 20)
    Local $hIcon = __GUICtrlStatusBar_SetIcon($Statusbar, 1, 0, 'ico.ico') ;the original udf destroys the icon handle
    Local $Icon = GUICtrlCreateIcon('ico.ico', -1, 300, 130, 16, 16) ;Icon on GUI - place before GUISetState
    Local $AVI = GUICtrlCreateAvi('avi.avi', 0, 250, 130, 16, 16)
    GUICtrlSetState($AVI, 1)
    Local $hAVI2 = _GUICtrlAVI_Create($WindowMain, 'avi.avi', -1, 154, 4, 16, 16)
    _GUICtrlStatusBar_EmbedControl($Statusbar, 0, $hAVI2, 1 + 2)
    _GUICtrlAVI_Play($hAVI2)
    GUISetState(@SW_SHOW)
    Local $GuiMsg
    Do
        $GuiMsg = GUIGetMsg()
    Until $GuiMsg = $GUI_EVENT_CLOSE
    _WinAPI_DestroyIcon($hIcon)
    Return
EndFunc   ;==>_example1

Func _example3()
    Local $WindowMain = GUICreate("Example", 351, 176, -1, -1)
    GUISetBkColor(0xDDDDDD, $WindowMain)
    Local $Statusbar = _GUICtrlStatusBar_Create($WindowMain)
    DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", $Statusbar, "wstr", 0, "wstr", 0)
    _GUICtrlStatusBar_SetBkColor($Statusbar, 0xDDDDDD)
    Local $Statusbar_PartsWidth[2] = [324, -1]
    _GUICtrlStatusBar_SetParts($Statusbar, $Statusbar_PartsWidth)
    _GUICtrlStatusBar_SetText($Statusbar, "", 0)
    _GUICtrlStatusBar_SetText($Statusbar, "", 1)
    _GUICtrlStatusBar_SetMinHeight($Statusbar, 20)
    Local $hIcon = __GUICtrlStatusBar_SetIcon($Statusbar, 1, 0, 'ico.ico') ;the original udf destroys the icon handle
    Local $Icon = GUICtrlCreateIcon('ico.ico', -1, 300, 130, 16, 16) ;Icon on GUI - place before GUISetState
    Local $AVI = GUICtrlCreateAvi('avi.avi', 0, 250, 130, 16, 16)
    GUICtrlSetState($AVI, 1)
    Local $AVI2 = GUICtrlCreateAvi('avi.avi', 0, 154, 4, 16, 16)
    Local $hAVI2 = GUICtrlGetHandle(-1)
    GUICtrlSetState($AVI2, 1)
    _GUICtrlStatusBar_EmbedControl($Statusbar, 0, $hAVI2, 1 + 2)
    GUISetState(@SW_SHOW)
    Local $GuiMsg
    Do
        $GuiMsg = GUIGetMsg()
    Until $GuiMsg = $GUI_EVENT_CLOSE
    _WinAPI_DestroyIcon($hIcon)
    Return
EndFunc   ;==>_example2

Func __GUICtrlStatusBar_SetIcon($hWnd, $iPart, $iIcon = 0, $sIconFile = "")
    Local $tIcon = DllStructCreate("handle")
    Local $vResult = DllCall("shell32.dll", "uint", "ExtractIconExW", "wstr", $sIconFile, "int", $iIcon, "ptr", 0, "struct*", $tIcon, "uint", 1)
    If @error Then Return SetError(@error, @extended, False)
    $vResult = $vResult[0]
    If $vResult > 0 Then $vResult = _SendMessage($hWnd, $SB_SETICON, $iPart, DllStructGetData($tIcon, 1), 0, "wparam", "handle")
    Return DllStructGetData($tIcon, 1)
EndFunc   ;==>__GUICtrlStatusBar_SetIcon
Edited by rover
  • Like 1

I see fascists...

Share this post


Link to post
Share on other sites
mvk25

Thank you Rover :) example 1 works great.

And I am sorry for the late reply, I was away from home for while.

Share this post


Link to post
Share on other sites
rover

Another option is an animated GIF or SWF file, there are udfs in the examples forum.


I see fascists...

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  

  • Similar Content

    • KaFu
      By KaFu
      ICU - Icon Configuration Utility

      Current Version: v6 (2018-Sep-16)
      Restore your desktop when the icons get "rearranged".
      Melba23 and I found we were working on very similar ideas to restore the Desktop icons to their normal place if they became "rearranged" (
      ). Vista seems to like this doing on occasion just for fun - but we all know some apps and games which change the display resolution or move icons around. This annoys "tidy" people who like their desktops arranged "just so" - I am particularly thinking of this desktop when I say that!
      We combined efforts and here is the result of our labors.
      Operation is easy - press "Save" to store a particular configuration and "Restore" to reset the icons to the saved positions in the selected configuration file. "Delete" allows you to remove unwanted configuration files from the list. There is a command line option so that the restoration can be run via HotKeys if required (that is why the script warns that it should be compiled for full functionality). You can decide what to do with any icons that have been added since you last saved the configuration file - the default is to put them in the top-left corner, but you can also banish them way off-screen or, more sensibly, specify a location for them.
      A new feature as of ICU v3.4 is the optional Desktop Contextmenu Integration (DCI) for Win7 (Win7 only because Microsoft implemented an easy way to do this through the registry as of this release).
      Version 3.3 should fix the empty save file bug
      Version 3.4 Win7: Admin rights no longer needed for DCI
      Version 5.0 Win8 compatibility for DCI
      The source and executable can be downloaded from my site: http://www.funk.eu
      Kudos to Ascend4nt, Melba23, Prog@ndy, & Valik for parts of the code.
      Please let me know if you found some piece of code in the source for which I forgot to mention a credit.
      Enjoy, let me know what you think of ICU and with Best Regards
    • FrancescoDiMuro
      By FrancescoDiMuro
      Good evening everyone
      First, I want to apologize with you for the title not very clear, but I thought a little bit on which title to set at the thread, and this is the one that came in mind.
      Now, let me explain what I'm trying to understand.

      I am making an application ( with n clients ), with an SQLite Database, which has a Main form, and n sub-forms... 
      Since these sub-forms are called several times, because they are used to add or update records to the Database, I put the code that generates the GUI of these sub-forms in Functions.
      There are two sub-forms which are "treated" as two main forms, since even them have n sub-forms, which perform various tasks.
      Where am I stucked?

      For the Main form I created a Status Bar, in order to display messages ( add/delete/update/search results ), and it works perfectly with all the forms which don't have other sub-forms.
      For the two forms, which indeed have n sub-forms, I created two separated Status Bars, which are (re)created everytime I call the function that then displays the form.
      Practically, I can't set icons to these two Status Bars, and I don't know why.
      I'm really sorry that I don't feel clear enough, so, here you are an example of what I am saying.
      I recreated exactly what my script does:
      #include <GuiButton.au3> #include <GUIConstantsEx.au3> #include <GuiStatusBar.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) Global $frmSubForm, _ $txtSubFormField, _ $sbSubFormStatusBar, _ $objSB_IconError = _WinAPI_LoadShell32Icon(109), _ $objSB_IconInformation = _WinAPI_LoadShell32Icon(277) #Region ### START Koda GUI section ### Form= $frmMainForm = GUICreate("Main Form", 300, 300, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "ExitApplication") $sbMainStatusBar = _GUICtrlStatusBar_Create($frmMainForm) $btnCreateSubForm = GUICtrlCreateButton("Create Sub Form", 105, 110, 75, 41, BitOR($BS_CENTER,$BS_VCENTER,$BS_MULTILINE)) GUICtrlSetOnEvent(-1, "GenerateSubForm") GUICtrlSetFont(-1, 10, 400, 0, "Arial") _GUICtrlStatusBar_SetSimple($sbMainStatusBar) _GUICtrlStatusBar_SetText($sbMainStatusBar, "") GUISetState(@SW_SHOW, $frmMainForm) #EndRegion ### END Koda GUI section ### While 1 Sleep(100) WEnd Func ExitApplication() Exit EndFunc Func GenerateSubForm() #Region ### START Koda GUI section ### Form= $frmSubForm = GUICreate("Sub-Form", 300, 300, -1, -1, -1, -1, $frmMainForm) GUISetOnEvent($GUI_EVENT_CLOSE, "DeleteSubForm") $txtSubFormField = GUICtrlCreateInput("", 0, 0, 100, 20) $btnCheckSubFormField = GUICtrlCreateButton("Check Field", 105, 110, 75, 41, BitOR($BS_CENTER,$BS_VCENTER,$BS_MULTILINE)) GUICtrlSetOnEvent(-1, "CheckSubFormField") GUICtrlSetFont(-1, 10, 400, 0, "Arial") $sbSubFormStatusBar = _GUICtrlStatusBar_Create($frmSubForm) _GUICtrlStatusBar_SetSimple($sbSubFormStatusBar) _GUICtrlStatusBar_SetText($sbSubFormStatusBar, "") GUISetState(@SW_SHOW, $frmSubForm) GUISetState(@SW_DISABLE, $frmMainForm) #EndRegion ### END Koda GUI section ### EndFunc Func DeleteSubForm() ; Declared Globally => $frmSubForm GUIDelete($frmSubForm) GUISetState(@SW_ENABLE, $frmMainForm) EndFunc Func WriteToStatusBar($sbStatusBar, $objSB_Icon, $strText) _GUICtrlStatusBar_SetIcon($sbStatusBar, 0, $objSB_Icon) _GUICtrlStatusBar_SetText($sbStatusBar, $strText) ConsoleWrite("Icon Handle: " & $objSB_Icon & @CRLF) EndFunc Func CheckSubFormField() ; Declared Globally => $txtSubFormField If GUICtrlRead($txtSubFormField) = "" Then ; Declared Globally => $sbStatusBar WriteToStatusBar($sbSubFormStatusBar, $objSB_IconError, "Field NOK.") Else WriteToStatusBar($sbSubFormStatusBar, $objSB_IconInformation, "Field OK.") EndIf EndFunc The text is set, but icon is not.
      Could someone please tell me why?
      Thanks everyone in advance  

      Best Regards.
    • Sven-Seyfert
      By Sven-Seyfert
      Hi Community,

      I'm looking for a way to do a Video Overlay GUI or something like that. The idea is to create a GUI which plays a video loop (with transparency/alpha channel) in front of an other GUI. Before you asking why - because I don't believe that GDIPlus can do it out of the box. My skillset for that kind of graphical things isn't good enough to do that, but here are some specialist like @UEZ maybe who can help.

      Example alpha channel video (visualized as animated *.gif):

      I tried to do the light rays effect directly with GDIPlus, but honestly that's a bit too difficult for me. I would be very glad and grateful if there are some suggestions, ideas or recommendations.

      Code for the Video play:
       
      Example video "End.mpeg":
       
      The next challenge is that the overlay GUI should be not clickable. If I hover over the overlay area, I want to have the possibility to control the GUI or what ever, in the background. But if there is any chance to make it with GDIPlus as a Video Overlay for light rays, I would prefer that approach instead of my crazy work-around idea.

      Thanks for any suggestion - I'm grateful!
      Sven
    • mar3011
      By mar3011
      Hey, I have a problem I tried to look for it but it didn't solve the problem, I can't add an icon to the exe, I already know there were such topics I tried to all add exclusion C: \ Users \ Marcin \ AppData \ Local \ AutoIt v3 \ aut472.tm.exe to antivirus but after compilation, the name of the file changes, I uninstalled the anti-virus, but it didn't works, except that when I add the example icons from AutoIT it works, I downloaded icons using Firefox Developer Edition also don't works, just the downloaded graphics don't works also. Is there any solution to this problem?  
×