Jump to content
Sign in to follow this  
bub

Gui color transparent gradation

Recommended Posts

bub

Try this script:

#include <GDIPlus.au3>

;~ Background Image
_GDIPlus_Startup()
$Image_BK = @ProgramFilesDir & "\AutoIt3\Examples\GUI\Torus.png"
$BKF = _GDIPlus_ImageLoadFromFile($Image_BK)
$iW_One = _GDIPlus_ImageGetWidth($BKF)
$iH_One = _GDIPlus_ImageGetHeight($BKF)
$hBitmap_BK = _GDIPlus_BitmapCloneArea($BKF, 0, 0, $iW_One, $iH_One, $GDIP_PXF32ARGB)
$hBmp_BK = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_BK)
_GDIPlus_BitmapDispose($hBitmap_BK)
_GDIPlus_ImageDispose($BKF)
_GDIPlus_Shutdown()

$Gui = GUICreate("My Trasparent",$iW_One, $iH_One, Default, Default,0x80000000);Style: $WS_POPUP
GUISetBkColor(0x000000); BackGround color Black
WinSetTrans($Gui,"",0); Trasparent GUI
GUISetState(@SW_SHOW,$Gui); Show Gui
$Img = GUICtrlCreatePic("",0,0,$iW_One, $iH_One) ;Create pic
 GUICtrlSendMsg($Img, 0x0172, 0, $hBmp_BK) ;insert img

While 1
    Switch GUIGetMsg()
        case -3 ;$Gui_event_close
            Exit
        EndSwitch
    WEnd

looks the image:

Posted Image

the gradation transparent of the image is changed! how to solve?

How can I put an image gradation as a form of GUI ?

excuse my English, I'm Italian

Share this post


Link to post
Share on other sites
UEZ

Try this:

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

Global $hGUI, $hImage, $hGraphic, $hImage
Global Const $SC_DRAGMOVE = 0xF012
_GDIPlus_Startup()
; Load PNG image
$hImage = _GDIPlus_ImageLoadFromFile(@ProgramFilesDir & "\AutoIt3\Examples\GUI\Torus.png")
$iWidth = _GDIPlus_ImageGetWidth($hImage)
$iHeight = _GDIPlus_ImageGetHeight($hImage)

; Create GUI
$hGUI = GUICreate("Show PNG", $iWidth, $iHeight, -1, -1, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_TOPMOST)
$hGUI_child = GUICreate("", $iWidth, $iHeight, 0, 0, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_TOPMOST + $WS_EX_MDICHILD, $hGUI)
$hButton = GUICtrlCreateButton("Exit", $iWidth * 2 / 3, $iHeight * 2 / 3, 40, 40)
GUISetBkColor(0xFFFFFF, $hGUI_child)
GUISetState(@SW_SHOW, $hGUI)
GUISetState(@SW_SHOW, $hGUI_child)
SetTransparentBitmap($hGUI, $hImage)
_WinAPI_SetLayeredWindowAttributes($hGUI_child, 0xFFFFFF, 0xff)

$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI_child)
_GDIPlus_GraphicsSetSmoothingMode($hGraphic, 2)
_GDIPlus_GraphicsDrawString($hGraphic, "GDI+ Full Transparency", 0, $iHeight / 2 - 20, "Arial", 12)

GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $hButton
            GUIRegisterMsg($WM_LBUTTONDOWN, "")
            _GDIPlus_ImageDispose($hImage)
            _GDIPlus_GraphicsDispose($hGraphic)
            _GDIPlus_Shutdown()
            GUIDelete($hGUI)
            ExitLoop
    EndSwitch
WEnd

Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
    _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
EndFunc   ;==>_WM_LBUTTONDOWN

Func SetTransparentBitmap($hGUI, $hImage, $iOpacity = 0xFF)
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
    $hScrDC = _WinAPI_GetDC(0)
    $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage))
    DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", $iOpacity)
    DllStructSetData($tBlend, "Format", 1)
    _WinAPI_UpdateLayeredWindow($hGUI,  $hMemDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
    _WinAPI_ReleaseDC(0, $hScrDC)
    _WinAPI_SelectObject($hMemDC, $hOld)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteDC($hMemDC)
EndFunc   ;==>SetTransparentBitmap

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
bub

I do not see the image...

is mandatory to use 2 GUI?

Edited by bub

Share this post


Link to post
Share on other sites
taietel

bub, in SetTransparentBitmap function, replace

_WinAPI_UpdateLayeredWindow($hGUI, $hGUI, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)

with

_WinAPI_UpdateLayeredWindow($hGUI, $hMemDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)

taietel

Share this post


Link to post
Share on other sites
UEZ

I do not see the image...

is mandatory to use 2 GUI?

It is only an example with a GUI and its child GUI. You can use also only one GUI if you wish.

@taietel: I thought I had fixed it in the past :)

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
bub

Posted Image

is a very good job, but I load a PNG and its transparency has been altered

Share this post


Link to post
Share on other sites
UEZ

Can you post your code please? And it seems to be that you used 2 images!

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
bub

the code is:

#include <GDIPlus.au3>

Global  $hGraphic

_GDIPlus_Startup()
; Load PNG image
$hImage = _GDIPlus_ImageLoadFromFile("main.png")
$iWidth = _GDIPlus_ImageGetWidth($hImage)
$iHeight = _GDIPlus_ImageGetHeight($hImage)

Dim $Image_OneButton = @ProgramFilesDir & "\AutoIt3\Examples\GUI\Torus.png"
$hImage_One = _GDIPlus_ImageLoadFromFile($Image_OneButton)
$iW_One = _GDIPlus_ImageGetWidth($hImage_One)
$iH_One = _GDIPlus_ImageGetHeight($hImage_One)
$hBitmap_One = _GDIPlus_BitmapCloneArea($hImage_One, 0, 0, $iW_One, $iH_One, $GDIP_PXF32ARGB)
$hBmp_One = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_One)
_GDIPlus_BitmapDispose($hBitmap_One)
_GDIPlus_ImageDispose($hImage_One)


; Create GUI
$hGUI = GUICreate("Show PNG", $iWidth, $iHeight, -1, -1, -2147483648, 524296)
$hGUI_child = GUICreate("", $iWidth, $iHeight, 0, 0,-2147483648 , 524360, $hGUI)



$hButton = GUICtrlCreateButton("Exit", $iWidth * 2 / 3, $iHeight * 2 / 3, 40, 40)
$a = GUICtrlCreatePic("",46,46,$iW_One,$iH_One)
 GUICtrlSendMsg($a , 0x0172, 0, $hBmp_One)
GUISetBkColor(0xCCFFCC, $hGUI_child)
GUISetState(@SW_SHOW, $hGUI)
GUISetState(@SW_SHOW, $hGUI_child)
SetTransparentBitmap($hGUI, $hImage)
_WinAPI_SetLayeredWindowAttributes($hGUI_child, 0xCCFFCC, 0xff)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case -3, $hButton

            _GDIPlus_ImageDispose($hImage)
            _GDIPlus_GraphicsDispose($hGraphic)
            _GDIPlus_Shutdown()
            GUIDelete($hGUI)
            ExitLoop
    EndSwitch
WEnd



Func SetTransparentBitmap($hGUI, $hImage, $iOpacity = 0xFF)
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
    $hScrDC = _WinAPI_GetDC(0)
    $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage))
    DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", $iOpacity)
    DllStructSetData($tBlend, "Format", 1)
  _WinAPI_UpdateLayeredWindow($hGUI, $hMemDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
    _WinAPI_ReleaseDC(0, $hScrDC)
    _WinAPI_SelectObject($hMemDC, $hOld)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteDC($hMemDC)
EndFunc

this is main.png:

http://img232.imageshack.us/img232/4507/mainrp.png

Share this post


Link to post
Share on other sites
taietel

Darn, I can't edit my post!!!... Also have problems with reply (tried with Chrome, Opera, IE)!... "You must enter a post."

bub, take a look at this script of Yashied (you also need his WinAPIEx UDF)

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


_GDIPlus_Startup()
;replace these images with your own:
$hBackground = _GDIPlus_ImageLoadFromFile(@ScriptDir & '\bg_440x440.png');put here your background image
$hReg = _GDIPlus_ImageLoadFromFile(@ScriptDir & '\Red.png')
$hYellow = _GDIPlus_ImageLoadFromFile(@ScriptDir & '\Yellow.png')


$State = Default


$hForm = GUICreate('', 440, 440, -1, -1, $WS_POPUPWINDOW, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))
_Update(0)
GUISetState()




While 1
    $Info = GUIGetCursorInfo($hForm)
    If @error Then
        _Update(0)
    Else
        If ($Info[0] >=120) And ($Info[0] <=320) And ($Info[1] >=120) And ($Info[1] <=320) And (BitAND(_GDIPlus_BitmapGetPixel($hReg, $Info[0] - 120, $Info[1] - 120), 0xFF000000) = 0xFF000000) Then
            _Update(1)
            If $Info[2] Then
                ExitLoop
            EndIf
        Else
            _Update(0)
        EndIf
    EndIf
    $Msg = GUIGetMsg()
    Switch $Msg
        Case -3
            ExitLoop
    EndSwitch
WEnd


_GDIPlus_Shutdown()


Func _Update($iState)


    If $iState = $State Then
        Return
    EndIf


    Local $hGraphic, $hImage


    $hImage = _GDIPlus_ImageClone($hBackground)
    $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage)
    Switch $iState
        Case 0
            _GDIPlus_GraphicsDrawImageRect($hGraphic, $hYellow, 120, 120, 200, 200)
        Case 1
            _GDIPlus_GraphicsDrawImageRect($hGraphic, $hReg, 120, 120, 200, 200)
    EndSwitch
    _WinAPI_UpdateLayeredWindowEx($hForm, _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage), 255, 1)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_ImageDispose($hImage)
    $State = $iState
EndFunc   ;==>_Update


Func _GDIPlus_BitmapGetPixel($hBitmap, $iX, $iY)


    Local $aResult = DllCall($ghGDIPDll, 'uint', 'GdipBitmapGetPixel', 'ptr', $hBitmap, 'int', $iX, 'int', $iY, 'ptr*', 0)


    If @error Then
        Return SetError(1, 0, 0)
    Else
        If $aResult[0] Then
            Return SetError($aResult[0], 0, 0)
        EndIf
    EndIf
    Return $aResult[4]
EndFunc   ;==>_GDIPlus_BitmapGetPixel


Func _GDIPlus_ImageClone($hImage)


    Local $aResult = DllCall($ghGDIPDll, 'uint', 'GdipCloneImage', 'ptr', $hImage, 'ptr*', 0)


    If @error Then
        Return SetError(1, 0, 0)
    Else
        If $aResult[0] Then
            Return SetError($aResult[0], 0, 0)
        EndIf
    EndIf
    Return $aResult[2]
EndFunc   ;==>_GDIPlus_ImageClone

[EDIT] JUST FOR TESTING

[EDIT2] I can edit my post, finally!

UEZ, nicely done! (tested the script below)

Edited by taietel

Share this post


Link to post
Share on other sites
UEZ

Prego:

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

Global $hGUI, $hImage, $hGraphic, $hImage
Global Const $SC_DRAGMOVE = 0xF012
_GDIPlus_Startup()
; Load PNG image
$hImage = _GDIPlus_ImageLoadFromFile("mainrp.png")
$hContext = _GDIPlus_ImageGetGraphicsContext($hImage)
$hImage2 = _GDIPlus_ImageLoadFromFile(@ProgramFilesDir & "\AutoIt3\Examples\GUI\Torus.png")
_GDIPlus_GraphicsDrawImage($hcontext, $hImage2, 150, 250)
$iWidth = _GDIPlus_ImageGetWidth($hImage)
$iHeight = _GDIPlus_ImageGetHeight($hImage)

; Create GUI
$hGUI = GUICreate("Show PNG", $iWidth, $iHeight, -1, -1, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_TOPMOST)
$hGUI_child = GUICreate("", $iWidth, $iHeight, 0, 0, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_TOPMOST + $WS_EX_MDICHILD, $hGUI)
$hButton = GUICtrlCreateButton("Exit", $iWidth * 2 / 3, $iHeight * 2 / 3, 40, 40)
GUISetBkColor(0xFFFFFF, $hGUI_child)
GUISetState(@SW_SHOW, $hGUI)
GUISetState(@SW_SHOW, $hGUI_child)
SetTransparentBitmap($hGUI, $hImage)
_WinAPI_SetLayeredWindowAttributes($hGUI_child, 0xFFFFFF, 0xff)

$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI_child)
_GDIPlus_GraphicsSetSmoothingMode($hGraphic, 2)

GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $hButton
            GUIRegisterMsg($WM_LBUTTONDOWN, "")
            _GDIPlus_ImageDispose($hImage)
            _GDIPlus_ImageDispose($hImage2)
            _GDIPlus_GraphicsDispose($hContext)
            _GDIPlus_GraphicsDispose($hGraphic)
            _GDIPlus_Shutdown()
            GUIDelete($hGUI)
            ExitLoop
    EndSwitch
WEnd

Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
    _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
EndFunc   ;==>_WM_LBUTTONDOWN

Func SetTransparentBitmap($hGUI, $hImage, $iOpacity = 0xFF)
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
    $hScrDC = _WinAPI_GetDC(0)
    $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage))
    DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", $iOpacity)
    DllStructSetData($tBlend, "Format", 1)
    _WinAPI_UpdateLayeredWindow($hGUI,  $hMemDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
    _WinAPI_ReleaseDC(0, $hScrDC)
    _WinAPI_SelectObject($hMemDC, $hOld)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteDC($hMemDC)
EndFunc   ;==>SetTransparentBitmap

Ciao,

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
UEZ

WinAPIEx ->

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
bub

@taietel: your code not working

@UEZ: your code works, but I need to use a control Guictrlcreatepic to create dynamic buttons () ... There is no other way?

Edited by bub

Share this post


Link to post
Share on other sites
taietel

bub, what errors output to console? If you have WinAPIEx.au3 in your script directory or in ProgramFiles\AutoIt3\Include, there should be no problems.

Also this script answers to your last question, regarding dynamic buttons.

taietel

Share this post


Link to post
Share on other sites
bub

@taietel: your code, working! I inserted the UDF correctly, but do not open any window and not by any error!

It seems that it remains in the state of @ SW_HIDE!

Share this post


Link to post
Share on other sites
taietel

bub, that's because you have to put other images.

In the script posted at #9, replace those images with your own, as I've stated!

See the ;<<<<<<<<<<<<<<<<< sign:

$hBackground = _GDIPlus_ImageLoadFromFile(@ScriptDir & '\bg_440x440.png');<<<<<<<<<<<<< ;put here your background image

$hReg = _GDIPlus_ImageLoadFromFile(@ScriptDir & '\Red.png');<<<<<<<<<<<<< 

$hYellow = _GDIPlus_ImageLoadFromFile(@ScriptDir & '\Yellow.png');<<<<<<<<<<<<<

edit: again problems with replying

Edited by taietel

Share this post


Link to post
Share on other sites
UEZ

@taietel: your code not working

@UEZ: your code works, but I need to use a control Guictrlcreatepic to create dynamic buttons () ... There is no other way?

Try this and press the torus:

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

Global $hGUI, $hImage, $hGraphic, $hImage
Global Const $SC_DRAGMOVE = 0xF012
_GDIPlus_Startup()
; Load PNG image
$hImage = _GDIPlus_ImageLoadFromFile("mainrp.png")
$hContext = _GDIPlus_ImageGetGraphicsContext($hImage)
$hImage2 = _GDIPlus_ImageLoadFromFile(@ProgramFilesDir & "\AutoIt3\Examples\GUI\Torus.png")
_GDIPlus_GraphicsDrawImage($hcontext, $hImage2, 150, 250)
$iWidth = _GDIPlus_ImageGetWidth($hImage)
$iHeight = _GDIPlus_ImageGetHeight($hImage)
$iWidth2 = _GDIPlus_ImageGetWidth($hImage2)
$iHeight2 = _GDIPlus_ImageGetHeight($hImage2)

; Create GUI
$hGUI = GUICreate("Show PNG", $iWidth, $iHeight, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
$hGUI_child = GUICreate("", $iWidth, $iHeight, 0, 0, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_TOPMOST + $WS_EX_MDICHILD, $hGUI)
$hButton = GUICtrlCreateButton("Exit", $iWidth * 2 / 3, $iHeight * 2 / 3, 40, 40)
GUISwitch($hGUI)
$label = GUICtrlCreateLabel("", 170, 270, $iWidth2 - 55, $iHeight2 - 60)
GUICtrlSetBkColor(-1, -2)
GUISetBkColor(0xFFFFFF, $hGUI_child)
GUISetState(@SW_SHOW, $hGUI)
GUISetState(@SW_SHOW, $hGUI_child)
SetTransparentBitmap($hGUI, $hImage)
_WinAPI_SetLayeredWindowAttributes($hGUI_child, 0xFFFFFF, 0xff)

$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI_child)
_GDIPlus_GraphicsSetSmoothingMode($hGraphic, 2)

GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $hButton
            GUIRegisterMsg($WM_LBUTTONDOWN, "")
            _GDIPlus_ImageDispose($hImage)
            _GDIPlus_ImageDispose($hImage2)
            _GDIPlus_GraphicsDispose($hContext)
            _GDIPlus_GraphicsDispose($hGraphic)
            _GDIPlus_Shutdown()
            GUIDelete($hGUI)
            ExitLoop
        Case $label
            MsgBox(0, "Test", "Torus was pressed")
    EndSwitch
WEnd

Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
    _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
EndFunc   ;==>_WM_LBUTTONDOWN

Func SetTransparentBitmap($hGUI, $hImage, $iOpacity = 0xFF)
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
    $hScrDC = _WinAPI_GetDC(0)
    $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage))
    DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", $iOpacity)
    DllStructSetData($tBlend, "Format", 1)
    _WinAPI_UpdateLayeredWindow($hGUI,  $hMemDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
    _WinAPI_ReleaseDC(0, $hScrDC)
    _WinAPI_SelectObject($hMemDC, $hOld)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteDC($hMemDC)
EndFunc   ;==>SetTransparentBitmap

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
bub

Yes, I have already replaced, but the GUI does not appear...

buttons dynamic with two images PNG that change with the arrival of the mouse...

Edited by bub

Share this post


Link to post
Share on other sites
bub

#include <GDIPlus.au3>
Dim $Numero = 0
dim $Block[2]
Global $d[9][1]
Dim $Salt = 26
dim $timer_st = 2000

Func _Button($hImage1,$hImage2,$x,$y,$w,$h)

if $Numero > 0 Then
    ReDim $Block[$Numero+1]
ReDim $d[9][$Numero+1]
EndIf
$Block[$Numero] = False
$b = GUICtrlCreatePic("",$x,$y,$w,$h)
_SetBitmapToCtrl($b,$hImage1)
$d[0][$Numero] = $x
$d[1][$Numero] = $y
$d[2][$Numero] = $w
$d[3][$Numero] = $h
$d[4][$Numero] = $b
$d[5][$Numero] = $hImage2
$d[6][$Numero] = $hImage1


$Numero = $Numero +1
Return $d
EndFunc
Dim $Mouse_DK[2]
dim $Timer

Func _MouseDR($HD_GUI)
$Mouse_GI = MouseGetPos()
$Gui_Pos = WinGetPos($HD_GUI)
$Mouse_DK[0] = $Mouse_GI[0]-$Gui_Pos[0]
$Mouse_DK[1] = $Mouse_GI[1]-$Gui_Pos[1]
Return $Mouse_DK
EndFunc
Dim $style = True
Func _BMove($H_GUI)
if $style = True Then
if GUIGetStyle($H_GUI) <> 0x80000000 Then GUISetStyle(0x80000000,-1,$H_GUI)
$style = False
EndIf
$Mouse_DO = _MouseDR($H_GUI)
for $i = 0 to $Numero-1
if $Mouse_DO[0] > $d[0][$i] AND $Mouse_DO[0] < $d[0][$i]+$d[2][$i] AND $Mouse_DO[1] > $d[1][$i] AND  $Mouse_DO[1] < $d[1][$i]+$d[3][$i] Then
if $Block[$i] = False then
;########################################################;########################################################
;~ $Timer = TimerInit()

_SetBitmapToCtrl($d[4][$i],$d[5][$i])

$Block[$i] = True
EndIf ;########################################################

;~ if TimerDiff($Timer) > $timer_st and TimerDiff($Timer) < $timer_st+50 Then
;~  _SetBitmapToCtrl($d[4][$i],$d[6][$i])
;~  EndIf
;~ If TimerDiff($Timer) > $timer_st*2 Then
;~  $Block[$i] = False
;~  $Timer = TimerInit()
;~ EndIf
;########################################################;########################################################
Else
if $Block[$i] = True then
;~ _SetBitmapToCtrl($d[4][$i],$d[6][$i])
_SetBitmapToCtrl($d[4][$i],$d[6][$i])

$Block[$i] = False
EndIf
EndIf
Next
EndFunc
Func _BSEL($D_Sel)
    Return $D_Sel[4][UBound($D_Sel,2)-1]
EndFunc
Func _GuiCtrlCreateButton($hImage1,$hImage2,$x,$y,$w,$h)
    Return _BSEL(_Button($hImage1,$hImage2,$x,$y,$w,$h))
EndFunc

Func _SetBitmapToCtrl($CtrlId, $hBitmap)
GUICtrlSendMsg($CtrlId, 0x0172, 0, $hBitmap)
GUICtrlSetState($CtrlId, 16)
EndFunc
;~ http://img833.imageshack.us/img833/7545/28313051.png
;~;~
;~



Dim $Image[4] = [@ScriptDir&"\B1.png",@ScriptDir&"\B12.png",@ScriptDir&"\B2.png",@ScriptDir&"\Main.png"]
Dim $URLImage[4] = ["http://img833.imageshack.us/img833/7545/28313051.png", "http://img710.imageshack.us/img710/9777/b12e.png","http://img232.imageshack.us/img232/9708/34262995.png","http://img96.imageshack.us/img96/3060/maink.png"]


For $i_img = 0 to UBound($Image)-1
    if not FileExists($Image[$i_img]) Then

    $size = InetGetSize($URLImage[$i_img],1)
        $Share = InetGet($URLImage[$i_img],$Image[$i_img],1,1)
ProgressOn($Image[$i_img],"I am downloading image",-1,-1,16)
do
$downloading = Round((InetGetInfo($Share, 0)*100)/$Size,2)

Sleep(50)
ProgressSet($downloading,$downloading&"%")
Until InetGetInfo($Share,2) = True
ProgressOff()
        EndIf
Next

Sleep(1000)





Dim $hImage[4]
_GDIPlus_Startup()

for $i_img = 0 to UBound($Image)-1
    $LoadIMG = _GDIPlus_ImageLoadFromFile($Image[$i_img])
$iW = _GDIPlus_ImageGetWidth($LoadIMG)
$iH = _GDIPlus_ImageGetHeight($LoadIMG)
$CloneIMG = _GDIPlus_BitmapCloneArea($LoadIMG, 0, 0, $iW, $iH, $GDIP_PXF32ARGB)
$hImage[$i_img] = _GDIPlus_BitmapCreateHBITMAPFromBitmap($LoadIMG)
_GDIPlus_BitmapDispose($LoadIMG)
_GDIPlus_ImageDispose($CloneIMG)
Next


$Form1 = GUICreate("My Button", 647,375)
$main = GUICtrlCreatePic("",0,0,662,422)
GUICtrlSendMsg($main, 0x0172, 0, $hImage[3])
GUICtrlSetState($main,128)
$b1 = _GuiCtrlCreateButton($hImage[0],$hImage[1],230, 130, 230, 64)


GUISetState(@SW_SHOW)
GUISetState(@SW_SHOW,$Form1)


  Dim $GO = False
while 1
    _BMove($Form1)
;~

        Switch GUIGetMsg()
            case -3 ; $GUI_EVENT_CLOSE
                _GDIPlus_Shutdown()
                exit
            case $b1
_SetBitmapToCtrl($b1, $hImage[2])
                ConsoleWrite("Pressed")
                Sleep(500)

            EndSwitch
WEnd

this my script, It works, but they are not able to make semi-transparent gui

Edited by bub

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.