Klovis Posted June 29, 2011 Share Posted June 29, 2011 (edited) Well right now I have two pngs up but when I slide off the selected pngs number it's still there why is that and how do I fix it? expandcollapse popup#include <GUIConstantsEx.au3> #include <SliderConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <WinAPI.au3> Opt("MustDeclareVars", 1) Global Const $AC_SRC_ALPHA = 1 Global $Form1, $Slider1, $hSlider,$Label1,$v, $fGUI, $fHdle, $fImage, $yGUI, $yHdle, $yImage $Form1 = GUICreate("Demo", 160, 60, 192, 114) $Slider1 = GUICtrlCreateSlider(5, 16, 150, 45) GUICtrlSetLimit($Slider1,3,0) GUICtrlSetData($Slider1,0) $hSlider = GUICtrlGetHandle($Slider1) $Label1 = GUICtrlCreateLabel("0%", 64, 0, 30, 17) GUISetState() _GDIPlus_Startup() GUIRegisterMsg($WM_HSCROLL, "hscroll") Do Until GUIGetMsg() = $GUI_EVENT_CLOSE _GDIPlus_ImageDispose($fImage) _GDIPlus_ImageDispose($yImage) _GDIPlus_Shutdown() Func hscroll($hWnd, $iMsg, $iwParam, $ilParam) #forceref $v = GUICtrlRead($Slider1) $fImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\fox.png") $yImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\yell.png") If $ilParam = $hSlider Then GUICtrlSetData($Label1, $v) If $v = 2 Then $fGUI = GUICreate("Fox", 442, 599, -1, -1, -1, BitOR($WS_EX_LAYERED,$WS_EX_TOPMOST)) $fHdle = GUICtrlGetHandle($fGUI) GUISetState() SetBitMap1($fGUI, $fImage, 255) ElseIf $v = 0 Then WinClose("fox") _GDIPlus_ImageDispose($fImage) EndIf If $v = 3 Then $yGUI = GUICreate("Yell", 579, 595, -1, -1, -1, BitOR($WS_EX_LAYERED,$WS_EX_TOPMOST)) $yHdle = GUICtrlGetHandle($yGUI) GUISetState() SetBitMap2($yGUI, $yImage, 204) Else WinClose("Yell") _GDIPlus_ImageDispose($yImage) EndIf EndIf Return "GUI_RUNDEFMSG" EndFunc Func SetBitmap1($Form1, $fImage, $iOpacity) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($fImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize ) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($fImage)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($fImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha" , $iOpacity) DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA) _WinAPI_UpdateLayeredWindow($Form1, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC (0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC ($hMemDC) EndFunc Func SetBitmap2($Form1, $yImage, $iOpacity) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($yImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize ) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($yImage)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($yImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha" , $iOpacity) DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA) _WinAPI_UpdateLayeredWindow($Form1, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC (0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC ($hMemDC) EndFunc Edited June 29, 2011 by Klovis Link to comment Share on other sites More sharing options...
monoscout999 Posted June 30, 2011 Share Posted June 30, 2011 expandcollapse popup#include <GUIConstantsEx.au3> #include <SliderConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <WinAPI.au3> Opt("MustDeclareVars", 1) Global Const $AC_SRC_ALPHA = 1 Global $Form1, $Slider1, $hSlider, $Label1, $v, $fGUI, $fHdle, $fImage, $yGUI, $yHdle, $yImage $Form1 = GUICreate("Demo", 160, 60, 192, 114) $Slider1 = GUICtrlCreateSlider(5, 16, 150, 45) GUICtrlSetLimit($Slider1, 3, 0) GUICtrlSetData($Slider1, 0) $hSlider = GUICtrlGetHandle($Slider1) $Label1 = GUICtrlCreateLabel("0%", 64, 0, 30, 17) GUISetState() _GDIPlus_Startup() $fImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\fox.png") $yImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\yell.png") $yGUI = GUICreate("Yell", 579, 595, -1, -1, -1, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST)) GUISetBkColor(0) _WinAPI_SetLayeredWindowAttributes($fGUI, 0, 0) SetBitMap($yGUI, $yImage, 204) $fGUI = GUICreate("Fox", 442, 599, -1, -1, -1, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST)) SetBitMap($fGUI, $fImage, 255) GUIRegisterMsg($WM_HSCROLL, "hscroll") Do Until GUIGetMsg() = $GUI_EVENT_CLOSE _GDIPlus_ImageDispose($fImage) _GDIPlus_ImageDispose($yImage) _GDIPlus_Shutdown() Func hscroll($hWnd, $iMsg, $iwParam, $ilParam) $v = GUICtrlRead($Slider1) If $ilParam = $hSlider Then GUICtrlSetData($Label1, $v) If $v = 2 Then GUISetState(@SW_SHOW, $fGUI) Guisetstate(@SW_RESTORE,$Form1) ; Just to keep the focus and still use the arrows to slide Else GUISetState(@SW_HIDE, $fGUI) EndIf If $v = 3 Then GUISetState(@SW_SHOW, $yGUI) Guisetstate(@SW_RESTORE,$Form1) ; Just to keep the focus and still use the arrows to slide Else GUISetState(@SW_HIDE, $yGUI) EndIf EndIf Return "GUI_RUNDEFMSG" EndFunc ;==>hscroll Func SetBitmap($Form1, $fImage, $iOpacity) ; Only ONCE!!!!!! Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($fImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($fImage)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($fImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA) _WinAPI_UpdateLayeredWindow($Form1, $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 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