malu05 Posted February 4, 2009 Posted February 4, 2009 I was trying to make a "skin" gui. So i have a background PNG file and some button and slider PNG's. The backgorund works just fine and render as it should. However i am unable to get any other PNG files to render ontop of the background PNG. Here is the sample code: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #Include <WinAPI.au3> Global Const $AC_SRC_ALPHA = 1 Global $hGUI, $hImage, $hGraphic, $hImage1 $appname = "test" ; Create GUI ; Load PNG image _GDIPlus_StartUp() $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "/Grapichs/MAIN.png") $width = _GDIPlus_ImageGetWidth($hImage) $height = _GDIPlus_ImageGetHeight($hImage) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) GUIRegisterMsg($WM_PAINT, "MY_WM_PAINT") GUISetState() $GUI = GUICreate($appname, $width, $height, -1, -1, -1, $WS_EX_LAYERED) SetBitmap($GUI, $hImage, 0) GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") GUISetState() WinSetOnTop($GUI, "", 1) For $i = 0 To 255 Step 10 SetBitmap($GUI, $hImage, $i) Next $controlGui = GUICreate("ControlGUI", $width, $height, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $GUI) ;$pic = GUICtrlCreatePic("", 40, 40, 40, 40) When Uncommenting this code i can get it to work but it will leave a big white layer ontop of the PNG file ;GuiCtrlSetState(-1,$GUI_DISABLE) ;$hpic = GUICtrlGetHandle($pic) GUISetState() ;This is where the problems are. ;I try to create a Button obtop of that created PNG file, but all i get is nothing $hImage3 = _GDIPlus_ImageLoadFromFile(@ScriptDir & "/Grapichs/Button_Closewindow.png") $hGraphic3 = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsDrawImage($hGraphic3, $hImage3, 10, 0) ; Loop until user exits do until GUIGetMsg() = $GUI_EVENT_CLOSE ; Clean up resources _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hImage) _GDIPlus_ShutDown() ; Draw PNG image Func MY_WM_PAINT($hWnd, $Msg, $wParam, $lParam) _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_UPDATENOW) _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 50, 50) _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_VALIDATE) Return $GUI_RUNDEFMSG EndFunc ;=================================================================================================== ; Handle the WM_NCHITTEST for the layered window so it can be dragged by clicking anywhere on the image. ;=================================================================================================== Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) If ($hWnd = $GUI) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION EndFunc ;==>WM_NCHITTEST ;=================================================================================================== ; SetBitMap ;=================================================================================================== 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 So... 2 things. How can i get the other PNG's to render on top of that background PNG? And is there a way to "force-sort" them so they allways keep the right order? [center][u]WoW Machinima Tool[/u] (Tool for Machinima Artists) [/center]
malu05 Posted February 4, 2009 Author Posted February 4, 2009 ahh this can't be. There must be a way =( [center][u]WoW Machinima Tool[/u] (Tool for Machinima Artists) [/center]
Enforcer Posted February 5, 2009 Posted February 5, 2009 Post Images too... PLZ And we will see what we can do about it... [RU] Zone
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