Jump to content
Sign in to follow this  

TCP Slider

Recommended Posts

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

#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))

$pici = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\yeahtoy.png")
SetBitMap($picw, $pici, $data)




Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
  if ($hWnd = $picw) and ($iMsg = $WM_NCHITTEST) then Return $HTCAPTION

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_DeleteDC    ($hMemDC)

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...