Rawox Posted February 23, 2010 Share Posted February 23, 2010 Hi there, I changed a few things from a piece of code on these forums. (http://www.autoitscript.com/forum/index.php?showtopic=102961) I changed it so far to this: expandcollapse popup#include <GDIPlus.au3> #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> #include <StaticConstants.au3> Global Const $AC_SRC_ALPHA = 1 Global Const $Title = "Todo Corner" Global Const $Version = "2.0" Global Const $FullTitle = $Title & " " & $Version _GDIPlus_Startup() $pngSrc = @ScriptDir & "\GUIBK.png" ;This allows the png to be dragged by clicking anywhere on the main image. GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") $GUI = _GUICreate_Alpha($FullTitle, $pngSrc) $myGuiHandle = WinGetHandle($FullTitle) GUISetState() ;This is an invisible control container. You can create regular windows controls on this panel. $controlGui = GUICreate("ControlGUI", 450, 300, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $myGuiHandle) GUICtrlCreateButton ( "lol", 10, 10, 100, 20 ) GUICtrlSetBkColor($controlGui, 0xFF00FF) GUICtrlSetState(-1, $GUI_DISABLE) ;This png is draggable as if it were a child window. It has about 50 pixels at the top that allow it to be dragged $TransparentButtonTest = GUICreate("Test321", 1, 1, 1, 1, $WS_EX_MDICHILD, $WS_EX_LAYERED, $myGuiHandle) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE _GDIPlus_Shutdown() Exit EndSelect WEnd Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) If ($hwnd = WinGetHandle($FullTitle)) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION EndIf EndFunc Func _GUICreate_Alpha($sTitle, $sPath, $iX=-1, $iY=-1, $iOpacity=255) Local $hGUI, $hImage, $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hImage = _GDIPlus_ImageLoadFromFile($sPath) $width = _GDIPlus_ImageGetWidth($hImage) $height = _GDIPlus_ImageGetHeight($hImage) $hGUI = GUICreate($sTitle, $width, $height, $iX, $iY, $WS_POPUP, $WS_EX_LAYERED) $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", $width) DllStructSetData($tSize, "Y", $height) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", 1) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, 2) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteObject($hImage) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>_GUICreate_Alpha 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 ;==>SetBitmap Func _ImageDrawText($hImage, $sText, $iX = 0, $iY = 0, $iRGB = 0x000000, $iSize = 9, $iStyle = 0, $sFont = "Arial") Local $w, $h, $hGraphic1, $hBitmap, $hGraphic2, $hBrush, $hFormat, $hFamily, $hFont, $tLayout, $aInfo $w = _GDIPlus_ImageGetWidth($hImage) $h = _GDIPlus_ImageGetHeight($hImage) ;Create a new bitmap, this way the original opened png is left unchanged $hGraphic1 = _GDIPlus_GraphicsCreateFromHWND(_WinAPI_GetDesktopWindow()) $hBitmap = _GDIPlus_BitmapCreateFromGraphics($w, $h, $hGraphic1) $hGraphic2 = _GDIPlus_ImageGetGraphicsContext($hBitmap) ; Draw the original opened png into my newly created bitmap _GDIPlus_GraphicsDrawImageRect($hGraphic2, $hImage, 0, 0, $w, $h) ;Create the font $hBrush = _GDIPlus_BrushCreateSolid ("0xFF" & Hex($iRGB, 6)) $hFormat = _GDIPlus_StringFormatCreate() $hFamily = _GDIPlus_FontFamilyCreate ($sFont) $hFont = _GDIPlus_FontCreate ($hFamily, $iSize, $iStyle) $tLayout = _GDIPlus_RectFCreate ($iX, $iY, 0, 0) $aInfo = _GDIPlus_GraphicsMeasureString ($hGraphic2, $sText, $hFont, $tLayout, $hFormat) ;Draw the font onto the new bitmap _GDIPlus_GraphicsDrawStringEx ($hGraphic2, $sText, $hFont, $aInfo[0], $hFormat, $hBrush) ;Cleanup the no longer needed resources _GDIPlus_FontDispose ($hFont) _GDIPlus_FontFamilyDispose ($hFamily) _GDIPlus_StringFormatDispose ($hFormat) _GDIPlus_BrushDispose ($hBrush) _GDIPlus_GraphicsDispose ($hGraphic2) _GDIPlus_GraphicsDispose ($hGraphic1) ;Return the new bitmap Return $hBitmap EndFunc But I can't seem to add buttons or labels.. I tried it between those 2 lines: GUICtrlCreateButton ( "lol", 10, 10, 100, 20 ) GUICtrlSetBkColor($controlGui, 0xFF00FF) But it just doesn't work. It doesn't even work when I try it on the original example Could anyone please help? Thanks in advance, Cas Cornelissen 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