Klovis Posted June 22, 2011 Share Posted June 22, 2011 I want to set this image up to another gui via TCP so I can control the opacity of the image on my laptop with the image on my desktop. Credit to Paul for code expandcollapse popup#include <WinAPI.au3> #include <GDIPlus.au3> #include <WindowsConstants.au3> #include <GUIConstants.au3> Opt ("MustDelcareVars", 1) Global Const $AC_SRC_ALPHA = 1 Global $pici, $picw, $data $data = 255 $picw = GUICreate("Picture", @DesktopWidth, @DesktopHeight, -1, -1, -1, BitOR($WS_EX_TOPMOST,$WS_EX_LAYERED)) _GDIPlus_Startup() $pici = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\yeahtoy.png") SetBitMap($picw, $pici, $data) GUISetState() GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") do until GUIGetMsg() =$GUI_EVENT_CLOSE _GDIPlus_ImageDispose($pici) _GDIPlus_Shutdown() Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) if ($hWnd = $picw) and ($iMsg = $WM_NCHITTEST) then Return $HTCAPTION EndFunc Func SetBitmap($picw, $hImage, $iOpacity) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($pici) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize ) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($pici)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($pici)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha" , $iOpacity ) DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA) _WinAPI_UpdateLayeredWindow($picw, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC (0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC ($hMemDC) 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