Rawox Posted February 24, 2010 Share Posted February 24, 2010 (edited) Hi there, I'm trying to use transparent icons (5x5) in my GUI. But for some reason they are not transparent. I've included an image on which you can see my problem and of course the source code: expandcollapse popup#include <GDIPlus.au3> #include <GuiComboBox.au3> #include <File.au3> #include <Array.au3> #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> #include <ButtonConstants.au3> Opt ( "MustDeclareVars", 0 ) FileInstall ( "D:\Scripts\Todo Corner\background.png", @TempDir, 1 ) FileInstall ( "D:\Scripts\Todo Corner\grey.gif", @TempDir, 1 ) FileInstall ( "D:\Scripts\Todo Corner\close.ico", @TempDir, 1 ) FileInstall ( "D:\Scripts\Todo Corner\minimize.ico", @TempDir, 1 ) Global Const $AC_SRC_ALPHA = 1 Global Const $Title = "Todo Corner" Global Const $Version = "1.2" Global Const $FullTitle = $Title & " " & $Version Global Const $Author = "Cas Cornelissen" Global Const $AuthorNick = "Rawox" Global Const $ReleaseDate = "24-02-2010" _GDIPlus_Startup() $pngSrc = @ScriptDir & "\background.png" $hImage = _GDIPlus_ImageLoadFromFile ( $pngSrc ) $width = _GDIPlus_ImageGetWidth ( $hImage ) $height = _GDIPlus_ImageGetHeight ( $hImage ) $GUI = GUICreate( $FullTitle, $width, $height, -1, -1, $WS_POPUP, $WS_EX_LAYERED) SetBitmap ( $GUI, $hImage, 255 ) GUIRegisterMsg ( $WM_NCHITTEST, "WM_NCHITTEST" ) GUISetState ( ) WinSetOnTop ( $GUI, "", 1 ) $controlGui = GUICreate ( "Controls", $width, $height, 0, 0, $WS_POPUP, BitOR ( $WS_EX_LAYERED, $WS_EX_MDICHILD ), $GUI ) GUICtrlCreatePic ( @ScriptDir & "\grey.gif", 0, 0, $width, $height ) GUICtrlSetState ( -1, $GUI_DISABLE ) $CloseIcon = GUICtrlCreateIcon ( @ScriptDir & "\close.ico", -1, 20, 20, 5, 5 ) GUICtrlSetBkColor ( $CloseIcon, $GUI_BKCOLOR_TRANSPARENT ) Global Const $NrOfGreyLabels = 5 Global Const $NrOfWhitLabels = 1 Dim $GreyLabel[$NrOfGreyLabels] Dim $WhitLabel[$NrOfWhitLabels] $WhitLabel[0] = GUICtrlCreateLabel ( $FullTitle, 24, 23 ) $GreyLabel[0] = GUICtrlCreateLabel ( "Add Item", 34,270 ) $GreyLabel[1] = GUICtrlCreateLabel ( "Clear list", 115,270 ) $GreyLabel[2] = GUICtrlCreateLabel ( "Configuration", 200,270 ) $GreyLabel[3] = GUICtrlCreateLabel ( "About", 315,270 ) $GreyLabel[4] = GUICtrlCreateLabel ( "Quit", 395,270 ) $i = 0 Do GUICtrlSetBkColor ( $GreyLabel[$i], $GUI_BKCOLOR_TRANSPARENT ) GUICtrlSetColor ( $GreyLabel[$i], 0x909090 ) $i += 1 Until $i = $NrOfGreyLabels $i = 0 Do GUICtrlSetBkColor ( $WhitLabel[$i], $GUI_BKCOLOR_TRANSPARENT ) GUICtrlSetColor ( $WhitLabel[$i], 0xFFFFFF ) $i += 1 Until $i = $NrOfWhitLabels GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE hideWindow() EndSelect WEnd Func hideWindow() GUISetState ( @SW_HIDE, $controlGui ) GUISetState ( @SW_HIDE, $GUI ) Exit EndFunc Func exitProg() _WinAPI_DeleteObject($hImage) _GDIPlus_Shutdown() Exit EndFunc Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) If ($hWnd = $GUI) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION EndFunc Func SetBitmap($hGUI, $hImage, $iOpacity) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) EndFunc Edited February 24, 2010 by Rawox Link to comment Share on other sites More sharing options...
kaotkbliss Posted February 24, 2010 Share Posted February 24, 2010 this post might help2nd post in topic 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now