Jump to content
Sign in to follow this  

GDIPlus Multiple Images

Recommended Posts


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:

#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
$hImage   = _GDIPlus_ImageLoadFromFile(@ScriptDir & "/Grapichs/MAIN.png")
$width = _GDIPlus_ImageGetWidth($hImage)
$height = _GDIPlus_ImageGetHeight($hImage)
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
$GUI = GUICreate($appname, $width, $height, -1, -1, -1, $WS_EX_LAYERED)
SetBitmap($GUI, $hImage, 0)
WinSetOnTop($GUI, "", 1)
For $i = 0 To 255 Step 10
    SetBitmap($GUI, $hImage, $i)
$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
;$hpic = GUICtrlGetHandle($pic)

;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
until GUIGetMsg() = $GUI_EVENT_CLOSE

; Clean up resources

; 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)
; 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)
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]

Share this post

Link to post
Share on other sites

ahh this can't be.

There must be a way =(

[center][u]WoW Machinima Tool[/u] (Tool for Machinima Artists) [/center]

Share this post

Link to post
Share on other sites

Post Images too... PLZ And we will see what we can do about it...

[RU] Zone

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