Breaker Posted January 21, 2009 Share Posted January 21, 2009 Hi, Guys, I'm a bit sutck in here. I have read the other png topics, and I understand how the drawing of png works. However, maybe I got something wrong, but I would like to draw 2 different PNGs on one GUI - window. Here is my code: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <ButtonConstants.au3> #include <GDIPlus.au3> #Include <WinAPI.au3> Global $hImage, $hGraphic, $hImage1 $gui = GUICreate("test", 1024, 768, -1, -1) _GDIPlus_StartUp() $hImage = _GDIPlus_ImageLoadFromFile("Graph\button_ok.png") $hImage2 = _GDIPlus_ImageLoadFromFile("Graph\button_cancel.png") $hGraphic = _GDIPlus_GraphicsCreateFromHWND($gui) $hGraphic2 = _GDIPlus_GraphicsCreateFromHWND($gui) GUIRegisterMsg($WM_PAINT, "yestick") GUIRegisterMsg($WM_PAINT, "nocross") Func yestick($hWnd, $Msg, $wParam, $lParam) _WinAPI_RedrawWindow($gui, 0, 0, $RDW_UPDATENOW) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, 700, 153,16,16) Return $GUI_RUNDEFMSG EndFunc Func nocross($hWnd, $Msg, $wParam, $lParam) _WinAPI_RedrawWindow($gui, 0, 0, $RDW_UPDATENOW) _GDIPlus_GraphicsDrawImageRect($hGraphic2, $hImage2, 780, 153,16,16) Return $GUI_RUNDEFMSG EndFunc GUISetState() Unfortunately, only nocross gets drawn "yestick" does not. Maybe I switched the orders, but just cannot find the problem. Appreciate any help! Link to comment Share on other sites More sharing options...
KJohn Posted January 22, 2009 Share Posted January 22, 2009 Hi, Guys, I'm a bit sutck in here. I have read the other png topics, and I understand how the drawing of png works. However, maybe I got something wrong, but I would like to draw 2 different PNGs on one GUI - window. Here is my code: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <ButtonConstants.au3> #include <GDIPlus.au3> #Include <WinAPI.au3> Global $hImage, $hGraphic, $hImage1 $gui = GUICreate("test", 1024, 768, -1, -1) _GDIPlus_StartUp() $hImage = _GDIPlus_ImageLoadFromFile("Graph\button_ok.png") $hImage2 = _GDIPlus_ImageLoadFromFile("Graph\button_cancel.png") $hGraphic = _GDIPlus_GraphicsCreateFromHWND($gui) $hGraphic2 = _GDIPlus_GraphicsCreateFromHWND($gui) GUIRegisterMsg($WM_PAINT, "yestick") GUIRegisterMsg($WM_PAINT, "nocross") Func yestick($hWnd, $Msg, $wParam, $lParam) _WinAPI_RedrawWindow($gui, 0, 0, $RDW_UPDATENOW) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, 700, 153,16,16) Return $GUI_RUNDEFMSG EndFunc Func nocross($hWnd, $Msg, $wParam, $lParam) _WinAPI_RedrawWindow($gui, 0, 0, $RDW_UPDATENOW) _GDIPlus_GraphicsDrawImageRect($hGraphic2, $hImage2, 780, 153,16,16) Return $GUI_RUNDEFMSG EndFunc GUISetState() Unfortunately, only nocross gets drawn "yestick" does not. Maybe I switched the orders, but just cannot find the problem. Appreciate any help! GUIRegisterMsg($WM_PAINT, "yestick") GUIRegisterMsg($WM_PAINT, "nocross") Considered that nocross is the only one being updated because it is the last one to be registered against WM_PAINT and hence the only one? Kinda like $i=2 and then $i=5 implies that $i will carry only the value 5 and have no traces of the constant 2 anymore... A possible solution would be to combine nocross and yestick into a single function and register that against WM_PAINT... Link to comment Share on other sites More sharing options...
Breaker Posted January 22, 2009 Author Share Posted January 22, 2009 GUIRegisterMsg($WM_PAINT, "yestick") GUIRegisterMsg($WM_PAINT, "nocross") Considered that nocross is the only one being updated because it is the last one to be registered against WM_PAINT and hence the only one? Kinda like $i=2 and then $i=5 implies that $i will carry only the value 5 and have no traces of the constant 2 anymore... A possible solution would be to combine nocross and yestick into a single function and register that against WM_PAINT... Many thanks John, this solution works fine. Link to comment Share on other sites More sharing options...
rasim Posted January 22, 2009 Share Posted January 22, 2009 Example: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <ButtonConstants.au3> #include <GDIPlus.au3> #include <WinAPI.au3> Global $hImage, $hGraphic, $hImage1 $hGUI = GUICreate("test", 400, 300, -1, -1) _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile("c:\test.png") $hImage2 = _GDIPlus_ImageLoadFromFile("c:\Test2.png") $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) GUIRegisterMsg($WM_PAINT, "WM_PAINT") GUISetState() Do Until GUIGetMsg() = -3 _GDIPlus_ImageDispose($hImage) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() ; Draw PNG image Func WM_PAINT($hWnd, $Msg, $wParam, $lParam) _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_UPDATENOW) _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0) _GDIPlus_GraphicsDrawImage($hGraphic, $hImage2, 100, 100) _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_VALIDATE) Return $GUI_RUNDEFMSG EndFunc 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