Jump to content
Sign in to follow this  
playlet

---

Recommended Posts

playlet

---

Edited by playlet

Share this post


Link to post
Share on other sites
Yashied

#Include <GDIPlus.au3>
#Include <GUIConstantsEx.au3>
#Include <WinAPIEx.au3>
#Include <WindowsConstants.au3>

_GDIPlus_Startup()

$hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & '\bg_440x440.png')
$hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
_GDIPlus_ImageDispose($hImage)

$hForm = GUICreate('', 440, 440, 200, 200, $WS_POPUPWINDOW, $WS_EX_LAYERED)
_WinAPI_UpdateLayeredWindowEx($hForm, $hBitmap, 127)
$hPopup = GUICreate('', 380, 380, 200 + 30, 200 + 30, $WS_POPUP, $WS_EX_LAYERED, $hForm)
GUISetBkColor(0xABABAB)
$Edit = GUICtrlCreateEdit('', 20, 20, 340, 250)
$Slider = GUICtrlCreateSlider(20, 286, 340, 32)
GUICtrlSetLimit(-1, 100, 0)
GUICtrlSetData(-1, 50)
$Button = GUICtrlCreateButton('OK', 155, 344, 70, 23)
_WinAPI_SetLayeredWindowAttributes($hPopup, 0xABABAB, 0, $LWA_COLORKEY)

GUIRegisterMsg($WM_MOVE, 'WM_MOVE')
GUIRegisterMsg($WM_NCHITTEST, 'WM_NCHITTEST')

GUISetState(@SW_SHOW, $hForm)
GUISetState(@SW_SHOW, $hPopup)

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE, $Button
            ExitLoop
        Case $Slider
            _WinAPI_UpdateLayeredWindowEx($hForm, $hBitmap, 255 / 100 * GUICtrlRead($Slider))
    EndSwitch
WEnd

_GDIPlus_Shutdown()

Func WM_MOVE($hWnd, $iMsg, $wParam, $lParam)
    Switch $hWnd
        Case $hForm

            Local $X = BitAND($lParam, 0xFFFF), $Y = BitShift($lParam, 16)

            If $X > 0x7FFF Then
                $X -= 0x10000
            EndIf
            If $Y > 0x7FFF Then
                $Y -= 0x10000
            EndIf
            WinMove($hPopup, '', $X + 30, $Y + 30)
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_MOVE

Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
    Switch $hWnd
        Case $hForm
            Switch $iMsg
                Case $WM_NCHITTEST
                    Return $HTCAPTION
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NCHITTEST

WinAPIEx.au3

post-42455-12824347801277_thumb.png

Edited by Yashied

Share this post


Link to post
Share on other sites
playlet

---

Edited by playlet

Share this post


Link to post
Share on other sites
UEZ

Do you mean this:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinApi.au3>
#include <GDIPlus.au3>

$width = 200
$height = 200
$hwnd = GUICreate("Test", $width, $height, Default, Default, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_TOPMOST)
GUISetState(@SW_SHOW)
$bsize_x = 50
$bsize_y = 30
$child = GUICreate("", $bsize_x, $bsize_y, $width * 0.5 - $bsize_x * 0.5, $height * 0.5 - $bsize_y * 0.5, $WS_POPUP, $WS_EX_MDICHILD + $WS_EX_LAYERED, $hwnd)
$button = GUICtrlCreateButton ("Test", 0, 0, $bsize_x, $bsize_y)
_WinAPI_SetLayeredWindowAttributes($child, 0xFFFFFF, 160)
GUISetState(@SW_SHOW)

;~ GUISetBkColor (0xFFFFFF)

_GDIPlus_Startup ()
$Graphics = _GDIPlus_GraphicsCreateFromHWND ($hwnd)
$bitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $graphics)
$backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)

$ScreenDc = _WinAPI_GetDC($hWnd)
$gdibitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($bitmap)
$dc = _WinAPI_CreateCompatibleDC($ScreenDc)
_WinAPI_SelectObject($dc, $gdibitmap)
; _WinAPI_UpdateLayeredWindow parameters
$tSize = DllStructCreate($tagSIZE)
$pSize = DllStructGetPtr($tSize)
DllStructSetData($tSize, "X", $width)
DllStructSetData($tSize, "Y", $height)
$tSource = DllStructCreate($tagPOINT)
$pSource = DllStructGetPtr($tSource)
$tBlend = DllStructCreate($tagBLENDFUNCTION)
$pBlend = DllStructGetPtr($tBlend)
$alpha = 160
DllStructSetData($tBlend, "Alpha", $alpha)
DllStructSetData($tBlend, "Format", 0)
$tPoint = DllStructCreate($tagPOINT)
$pPoint = DllStructGetPtr($tPoint)
DllStructSetData($tPoint, "X", 0)
DllStructSetData($tPoint, "Y", 0)

$PenRect = _GDIPlus_PenCreate (0xFFFFAA00, 10)
_GDIPlus_GraphicsClear($backbuffer, 0x0)
_GDIPlus_GraphicsDrawRect($backbuffer, 0, 0, $width, $height, $PenRect)
$bild = _GDIPlus_ImageLoadFromFile("..\..\images\Bubbles_03.png") ;<=-- replace path with a transparency png
_GDIPlus_GraphicsDrawImageRect($backbuffer, $Bild, 50, 50, 100, 100)

$gdibitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($bitmap)
_WinAPI_SelectObject($dc, $gdibitmap)
_WinAPI_UpdateLayeredWindow($hWnd, $ScreenDc, 0, $pSize, $dc, $pSource, 0, $pBlend, 2)
_WinAPI_DeleteObject($gdibitmap)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case -3
            _GDIPlus_GraphicsDispose($backbuffer)
            _GDIPlus_BitmapDispose($bitmap)
            _WinAPI_DeleteDC($dc)
            _WinAPI_ReleaseDC($hWnd, $ScreenDc)
            _GDIPlus_GraphicsDispose($Graphics)
            _GDIPlus_Shutdown()
            $tSize = ""
            $tSource = ""
            $tBlend = ""
            $tPoint = ""
            GUIDelete($child)
            GUIDelete($hwnd)
    Exit
        Case $button
            WinSetOnTop($hwnd, "", False)
            MsgBox(0, "Transparenz", "von UEZ '2010")
            WinSetOnTop($hwnd, "", True)
    EndSwitch
WEnd

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
playlet

---

Edited by playlet

Share this post


Link to post
Share on other sites
playlet

---

Edited by playlet

Share this post


Link to post
Share on other sites
UEZ

This is working for me with only 1 window:

#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>

$width = 200
$height = 200
$hwnd = GUICreate("Test", $width, $height, Default, Default, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_TOPMOST)
GUISetBkColor(0x000001)
_WinAPI_SetLayeredWindowAttributes($hwnd, 0x00000001, 0x00, 1, 0)
GUISetState(@SW_SHOW)

_GDIPlus_Startup ()
$hGraphics = _GDIPlus_GraphicsCreateFromHWND ($hwnd)
$hImage = _GDIPlus_ImageLoadFromFile("..\images\Smiley.png") ;<=-- replace path with a transparency png
_GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, 0, 0, 200, 200)

$button = GUICtrlCreateButton ("Test", 75, 85, 50, 30)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case -3
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hwnd)
    Exit
    Case $button
    WinSetOnTop($hwnd, "", False)
    MsgBox(0, "Transparency", "by UEZ '2010")
    WinSetOnTop($hwnd, "", True)
    EndSwitch
WEnd

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
playlet

---

Edited by playlet

Share this post


Link to post
Share on other sites
UEZ

Nice. Any way to restore true transparency?

What do you mean exactly with restore true transparency?

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
playlet

---

Edited by playlet

Share this post


Link to post
Share on other sites
UEZ

With GDI+ it is, as far as I know, not possible to draw png's with full tranparency! Same issue with full transparent icons!

Sorry,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
playlet

---

Edited by playlet

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.