#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
;~ #Include <WinAPI.au3>
#Include <WinAPIEx.au3>
Opt('MustDeclareVars', 1)
Global $gui, $guiPos, $pic, $picPos
;----- example 3 PNG work araund by Zedna
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#Include <WinAPI.au3>
Global $hGUI, $hImage, $hGraphic, $hImage1, $hform
Global Const $SC_MOVE = 0xF010
_GDIPlus_StartUp()
$hform = GUICreate("abc",600,600,-1,-1)
GUISetBkColor(0xffffff,$hform)
;~ $hGUI = GUICreate("Show PNG", 400, 400,100,0,$WS_POPUP, BitOR($WS_EX_LAYERED,$WS_EX_MDICHILD), $hform) ; 分层
$hGUI = GUICreate("Show PNG", 400, 400,100,0,$WS_POPUP, $WS_EX_MDICHILD, $hform) ; 不分层
Global $color = 0xabcdef
GUISetBkColor($color,$hGUI)
_GDIPlus_StartUp()
$hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir&"\png-0011.png")
Global $p_w = _GDIPlus_ImageGetWidth($hImage)
Global $p_H = _GDIPlus_ImageGetWidth($hImage)
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
Global $p_x = 50
Global $p_y = 50
;~ _WinAPI_SetLayeredWindowAttributes($hGUI,0x010101)
;~ _WinAPI_SetLayeredWindowAttributes($hGUI,$color,255)
GUIRegisterMsg($WM_PAINT, "MY_WM_PAINT")
GUISetState(@SW_SHOW,$hGUI)
GUISetState(@SW_SHOW,$hform)
;~ _WinAPI_SetParent($hGUI, $hform)
;~ GUIRegisterMsg($WM_PAINT, "MY_WM_PAINT")
;~ GUIRegisterMsg($WM_LBUTTONDOWN,"WM_LBUTTONDOWN")
GUIRegisterMsg($WM_LBUTTONUP,"WM_LBUTTONUP")
;~ GUIRegisterMsg($WM_PAINT, "MY_WM_PAINT")
do
until GUIGetMsg() = $GUI_EVENT_CLOSE
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_ShutDown()
Func WM_LBUTTONUP($ihWnd,$iMsg,$iwParam,$ilParam)
If $ihWnd = $hGUI Then
Local $x = BitAND($ilParam, 0xFFFF)
Local $y = BitShift($ilParam, 16)
If _WinAPI_PtInRectEx($x, $y, $p_x, $p_y, $p_x+$p_w, $p_y+$p_H) = 1 Then
;~ MsgBox(0,"", "你点击了PNG")
ToolTip("你点击了PNG")
EndIf
EndIf
EndFunc
Func WM_LBUTTONDOWN($ihWnd,$iMsg,$iwParam,$ilParam)
If $ihWnd = $hGUI Then
Local $x = BitAND($ilParam, 0xFFFF)
Local $y = BitShift($ilParam, 16)
If _WinAPI_PtInRectEx($x, $y, $p_x, $p_y, $p_x+$p_w, $p_y+$p_H) = 1 Then
;~ MsgBox(0,"", "你点击了PNG")
ToolTip("你点击了PNG")
EndIf
EndIf
;~ Switch $ihWnd
;~ Case $hGUI
;~ _SendMessage($hGUI,$WM_SYSCOMMAND,$SC_MOVE+$HTCAPTION,0)
;~ EndSwitch
EndFunc
Func MY_WM_PAINT($hWnd, $Msg, $wParam, $lParam)
_WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_UPDATENOW)
_GDIPlus_GraphicsDrawImage($hGraphic, $hImage, $p_x, $p_y)
_WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_VALIDATE)
Return $GUI_RUNDEFMSG
EndFunc