Jump to content

Problem with multiple transparent gifs on "$WS_EX_LAYERED"


AndroidZero
 Share

Recommended Posts

Hello community !

I need help with my GUI Creation.
The window should look like this, its a transparent picture with a combobox control on it.
The problem is when I add another transparent gif on the current gif pic they lose transparency (picture 2)

 

Btw on my other GUI with another GIF Background it works its only with this GIF Pic...
Maybe it's a problem with the picture but i checked all relevant values in adobe photoshop for transparence there is no difference with the other picture in my opinion.
If you have a better idea how to create such a guis please let me know :)
Thank you !

yh3VdcU.pngnfiZzx3.png


I post a code to test on your own with 2 uploaded gif images.
 

Global $graphics_path = @ScriptDir & "\graphics"

GUI_Open_AccountManager()

Func GUI_Open_AccountManager()

Global $hGUIAccountManager = GUICreate("Account Manager", 350, 350, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))
GUISetOnEvent($GUI_EVENT_CLOSE, "GUI_Close_AccountManager")


$cbox = GUICtrlCreateCombo("",100,77,120,20,$CBS_DROPDOWNLIST)
_GUICtrlComboBox_AddString($cbox,"Account 1")
_GUICtrlComboBox_AddString($cbox,"Account 2")
_GUICtrlComboBox_AddString($cbox,"Account 3")
_GUICtrlComboBox_AddString($cbox,"Account 4")
_GUICtrlComboBox_AddString($cbox,"Account 5")
_GUICtrlComboBox_SelectString($cbox,"Account 2")

$pic = GUICtrlCreatePic($graphics_path & "\WindowAccountManager.gif", 0, 0, 350, 350,-1, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

GUICtrlCreateLabel("Account: ",35,80,60)
GUICtrlSetFont(-1,$fontSize_TextBody,$fontWeight_TextBody,0,$fontName_TextBody,1)
GUICtrlSetColor(-1,$fontColor_TextBody)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

GUICtrlCreateCombo("Account 2",100,77,120,20,$CBS_DROPDOWNLIST)
GUICtrlCreatePic($graphics_path & "\sbutton_login.gif",230, 80, 75, 15)


GUISetState(@SW_SHOW,$hGUIAccountManager)
EndFunc

 

WindowAccountManager.gif

sbutton_login.gif

Edited by AndroidZero
Link to comment
Share on other sites

You can use GDI+ to display the image properly:

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiComboBox.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>

Global $graphics_path = @ScriptDir

GUI_Open_AccountManager()

Func GUI_Open_AccountManager()
    _GDIPlus_Startup()
    Global $hGUIAccountManager = GUICreate("Account Manager", 350, 350, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))


    $cbox = GUICtrlCreateCombo("",100,77,120,20,$CBS_DROPDOWNLIST)
    _GUICtrlComboBox_AddString($cbox,"Account 1")
    _GUICtrlComboBox_AddString($cbox,"Account 2")
    _GUICtrlComboBox_AddString($cbox,"Account 3")
    _GUICtrlComboBox_AddString($cbox,"Account 4")
    _GUICtrlComboBox_AddString($cbox,"Account 5")
    _GUICtrlComboBox_SelectString($cbox,"Account 2")

    $pic = GUICtrlCreatePic($graphics_path & "\WindowAccountManager.gif", 0, 0, 350, 350,-1, $GUI_WS_EX_PARENTDRAG)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

    GUICtrlCreateLabel("Account: ",35,80,60)
    GUICtrlSetFont(-1,10,0,0,"Arial",1)
    GUICtrlSetColor(-1,-2)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

    GUICtrlCreateCombo("Account 2",100,77,120,20,$CBS_DROPDOWNLIST)

    Local $iPic = GUICtrlCreatePic("", 230, 79)
    Local $hImg = _GDIPlus_ImageLoadFromFile($graphics_path & "\sbutton_login.gif")
    Local $hImg2 = _GDIPlus_ImageResize($hImg, 80, 18)
    Local $hHBMP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImg2, 0xFFFFFFFF)
    _WinAPI_DeleteObject(GUICtrlSendMsg($iPic, 0x0172, $IMAGE_BITMAP, $hHBMP))

    GUISetState(@SW_SHOW,$hGUIAccountManager)

    _WinAPI_SetLayeredWindowAttributes($hGUIAccountManager, 0x00FF33)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    _GDIPlus_ImageDispose($hImg)
    _GDIPlus_ImageDispose($hImg2)
    _WinAPI_DeleteObject($hHBMP)
    _GDIPlus_Shutdown()
EndFunc

 

Edited by UEZ
Made the GUI also transparent

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Thank your for the reply !
I read the whole GFIPlus section in the Help File and tested anything but still I can't figure out how to display 2 overlain transparent images.
Your example shows only the "login button" transparent but the picture which lays under it isn't showns transparent.

I can only display transparent gif with a <GIFAnimation.au3>
Here is an example how it works properly with this script included:

;************FOR GUI***********
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

;**********FOR FONTS **********
#include <FontConstants.au3>

;**********FOR COMBOBOX **********
#include <GuiComboBox.au3>

;**********FOR GIF ANIMATION **********
#include <GIFAnimation.au3>

Opt("GUIOnEventMode",1) ;OnEvent Modus für GUIs' , die dem User als Tool dienen.

;******** INIT TEMP VAR ************************
Global $fontSize_TextBody = 8.5, $fontName_TextBody = "", $fontWeight_TextBody = $FW_BOLD, $fontColor_TextBody = 0x5A2800
Global $graphics_path = @ScriptDir & "\graphics"
Global $draw = 0
Global $clear = 0
Global $infolabel1 = 0
Global $hGUIAccountManager = 0
;***********************************************

GUI_Open_AccountManager()

While 1
    $aCursor = GUIGetCursorInfo()
    If @error <> True Then
        If WinExists($hGUIAccountManager) And BitAND(WinGetState($hGUIAccountManager),2) Then
            If ($aCursor[0] >= 35 And $aCursor[0] <= 155 And $aCursor[1] >= 120 And $aCursor[1] <= 138) Then
                If $draw = 0 Then
                    GUICtrlSetData($infolabel1,"")
                    GUICtrlSetData($infolabel1,'Edit the current selected Account from the dropdown box.' & @CRLF & 'You can change here "Account Name", "Password",' & @CRLF & '"Account Label Name".')
                    $draw = 1
                    $clear = 0
                EndIf
            ElseIf ($aCursor[0] >= 170 And $aCursor[0] <= 290 And $aCursor[1] >= 120 And $aCursor[1] <= 138) Then
                If $draw = 0 Then
                    GUICtrlSetData($infolabel1,"")
                    GUICtrlSetData($infolabel1,'Add a new Account into your Account Manager.' & @CRLF & 'Type your Account Data in the proper entry fields and save it.')
                    $draw = 1
                    $clear = 0
                EndIf
            ElseIf ($aCursor[0] >= 305 And $aCursor[0] <= 425 And $aCursor[1] >= 120 And $aCursor[1] <= 138) Then
                If $draw = 0 Then
                    GUICtrlSetData($infolabel1,"")
                    GUICtrlSetData($infolabel1,"Delete the current selected Account from the dropdown box.")
                    $draw = 1
                    $clear = 0
                EndIf
            Else
                $draw = 0
                If $clear == 0 Then
                    ConsoleWrite("Delete label = " & $infolabel1 & @CRLF)
                    GUICtrlSetData($infolabel1,"Hover the desired button for more informations.")
                    $clear = 1
                EndIf
            EndIf
        EndIf
    EndIf
WEnd


Func GUI_Open_AccountManager()

Global $hGUIAccountManager = GUICreate("Account Manager", 460, 252, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))
GUISetOnEvent($GUI_EVENT_CLOSE, "GUI_Close_AccountManager")


GUICtrlCreatePic($graphics_path & "\sbutton_login.jpg",305, 80, 120, 18)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetCursor(-1,0)
GUICtrlSetOnEvent(-1,"GUI_Close_AccountManager")

GUICtrlCreatePic($graphics_path & "\sbutton_edit.jpg",35, 120, 120, 18)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetCursor(-1,0)
GUICtrlSetOnEvent(-1,"GUI_Close_AccountManager")

GUICtrlCreatePic($graphics_path & "\sbutton_add.jpg",170, 120, 120, 18)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetCursor(-1,0)
GUICtrlSetOnEvent(-1,"GUI_Close_AccountManager")

GUICtrlCreatePic($graphics_path & "\sbutton_delete.jpg",305, 120, 120, 18)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetCursor(-1,0)
GUICtrlSetOnEvent(-1,"GUI_Close_AccountManager")

$infolabel1 = GUICtrlCreateLabel("", 35, 160,490,90)
GUICtrlSetFont(-1,$fontSize_TextBody,$fontWeight_TextBody,0,$fontName_TextBody,1)
GUICtrlSetColor(-1,$fontColor_TextBody)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)


Global $cbox = GUICtrlCreateCombo("",100,77,120,20,$CBS_DROPDOWNLIST)
GUI_AccountManager_LoadAccounts()


$pics = GUICtrlCreatePic($graphics_path & "\WindowAccountManager.gif", 0, 0, 460, 252,-1, $GUI_WS_EX_PARENTDRAG)

GUICtrlCreateLabel("Account: ",35,80,60)
GUICtrlSetFont(-1,$fontSize_TextBody,$fontWeight_TextBody,0,$fontName_TextBody,1)
GUICtrlSetColor(-1,$fontColor_TextBody)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

GUICtrlCreateCombo(Guictrlread($cbox),100,77,120,20,$CBS_DROPDOWNLIST)

;GUICtrlCreatePic($graphics_path & "\sbutton_login.jpg",305, 80, 120, 18)
;GUICtrlCreatePic($graphics_path & "\sbutton_edit.jpg",35, 120, 120, 18)
;GUICtrlCreatePic($graphics_path & "\sbutton_add.jpg",170, 120, 120, 18)
;GUICtrlCreatePic($graphics_path & "\sbutton_delete.jpg",305, 120, 120, 18)
_GUICtrlCreateGIF($graphics_path & "\sbutton_login.jpg", "", 305, 80, 120, 18)
_GUICtrlCreateGIF($graphics_path & "\sbutton_edit.jpg", "", 35, 120, 120, 18)
_GUICtrlCreateGIF($graphics_path & "\sbutton_add.jpg", "", 170, 120, 120, 18)
_GUICtrlCreateGIF($graphics_path & "\sbutton_delete.jpg", "", 305, 120, 120, 18)

$infolabel1 = GUICtrlCreateLabel("Hover the desired button for more informations", 35, 160,490,90)
GUICtrlSetFont(-1,$fontSize_TextBody,$fontWeight_TextBody,0,$fontName_TextBody,1)
GUICtrlSetColor(-1,$fontColor_TextBody)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)


GUISetIcon(@ScriptDir & "\TibiaInfo.ico")
GUISetState(@SW_SHOW,$hGUIAccountManager)
EndFunc




Func GUI_Close_AccountManager()
    Exit
EndFunc

Func GUI_AccountManager_LoadAccounts()
$account_label = IniReadSectionNames(@ScriptDir & "\accmngmnt.ini")
    For $i= 1 To $account_label[0]
        _GUICtrlComboBox_AddString($cbox,$account_label[$i])
    Next
    _GUICtrlComboBox_SetCurSel($cbox,0)
EndFunc


Uploaded the images you need to test and the .ini file for loading entries into combo box and ofcorse the "GIFAnimation.au3"

WindowAccountManager.gif

sbutton_delete.jpg

sbutton_login.jpg

sbutton_edit.jpg

sbutton_add.jpg

accmngmnt.ini

GIFAnimation.au3

Edited by AndroidZero
Link to comment
Share on other sites

@AndroidZero: I didn't realized that the green border should be transparent, too. I updated the code above to make the GUI also transparent.

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

@UEZ: Thanks but still doesnt work.
I really appreciate the time you took for me but I noticed now that I didn't explain my problem well and what is my goal.
So before I start a new Topic I will try last time to explain it here more detailed and more accurate.
 

Screenshot of my current GUI POPUP Window:
Problem:

  • Background image has bad quality for some reason there are some wrong pixels set as transparent
  • InputBox Font is showns transparent
  • the second image (login button) is also full transparent and shine through the background image

kBMZp5q.png

As you see I used now GUICtrlCreatePic() for my transparent "gif images".

It almost works, only this transparent issues are annoying.

Goal:

  • Background image should be transparent in a good quality
  • any further gif images should be transparent but show the background image layer

 

CODE:

;************FOR GATHER HTML SOURCE CODE**********************
#include <IE.au3>
#include <InetConstants.au3>
;************FOR GUI***********
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPIFiles.au3>
;**********FOR BUTTON **********
#include <ButtonConstants.au3>
#include <StaticConstants.au3>
;**********FOR STRINGS **********
#include <StringConstants.au3>
#include <String.au3>
;**********FOR COMBOBOX **********
#include <StringConstants.au3>
#include <EditConstants.au3>
#include <GuiEdit.au3>
#include <GuiComboBox.au3>
;**********FOR FONTS **********
#include <FontConstants.au3>
;**********FOR PROCESS **********
#include <Process.au3>
#include <SendMessage.au3>
;*********FOR IMAGES ****************
#include <GDIPlus.au3>
;************************************************************

Opt("GUIOnEventMode",1)


Global $graphics_path = @ScriptDir & "\graphics"


GUI_Login()


Func GUI_Login()
Global $hGUISecurityLogin = GUICreate("Account Manager", 430, 180, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))
GUISetOnEvent($GUI_EVENT_CLOSE, "GUI_Close")

;Background Skin for GUI PopUp & Dragable
GUICtrlCreatePic($graphics_path & "\SecurityLoginWindowFrame.gif", 0, 0, 430, 180,-1, $GUI_WS_EX_PARENTDRAG)


;Some GUIControl Objects
GUICtrlCreateInput("Account Name",155,73,120,20)
GUICtrlCreateInput("Password",155,122,120,20)
GUICtrlCreatePic($graphics_path & "\sbutton_login_transparent.gif", 290, 146, 120, 18)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetCursor(-1, 0)
GUICtrlSetOnEvent(-1,"GUI_Close")


;Controls only accessible when controls created again...
GUICtrlCreatePic($graphics_path & "\sbutton_login_transparent.gif", 290, 146, 120, 18)
GUICtrlCreateInput("Account Name",155,73,120,20)
GUICtrlCreateInput("Password",155,122,120,20)



GUISetState(@SW_SHOW,$hGUISecurityLogin)
EndFunc


Func GUI_Close()
    Exit
EndFunc


While 1
    Sleep(10)
WEnd

 

SecurityLoginWindowFrame.gif

sbutton_login_transparent.gif

Edited by AndroidZero
Link to comment
Share on other sites

Is this better now?

;************FOR GATHER HTML SOURCE CODE**********************
#include <IE.au3>
#include <InetConstants.au3>
;************FOR GUI***********
#include <GUIConstantsEx.au3>
#include <GDIPlus.au3>
#include <SendMessage.au3>
#include <WindowsConstants.au3>
#include <WinAPIFiles.au3>
;**********FOR BUTTON **********
#include <ButtonConstants.au3>
#include <StaticConstants.au3>
;**********FOR STRINGS **********
#include <StringConstants.au3>
#include <String.au3>
;**********FOR COMBOBOX **********
#include <StringConstants.au3>
#include <EditConstants.au3>
#include <GuiEdit.au3>
#include <GuiComboBox.au3>
;**********FOR FONTS **********
#include <FontConstants.au3>
;**********FOR PROCESS **********
#include <Process.au3>
#include <SendMessage.au3>
;*********FOR IMAGES ****************
#include <GDIPlus.au3>
;************************************************************

Opt("GUIOnEventMode",1)


Global $hGUISecurityLogin, $graphics_path = @ScriptDir & "\graphics"
Global Const $SC_DRAGMOVE = 0xF012

GUI_Login()


Func GUI_Login()
$hGUISecurityLogin = GUICreate("Account Manager", 430, 180, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))
GUISetOnEvent($GUI_EVENT_CLOSE, "GUI_Close")

;Background Skin for GUI PopUp & Dragable
GUICtrlCreatePic($graphics_path & "\SecurityLoginWindowFrame.gif", 0, 0, 430, 180)
GUICtrlSetState(-1, $GUI_DISABLE)

;Some GUIControl Objects
Local $iPic = GUICtrlCreatePic("", 290, 146, 120, 18)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetCursor(-1, 0)

    _GDIPlus_Startup()
    Local $hImg = _GDIPlus_ImageLoadFromFile($graphics_path & "\sbutton_login_transparent.gif")
    Local $hHBMP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImg)
    _WinAPI_DeleteObject(GUICtrlSendMsg($iPic, 0x0172, $IMAGE_BITMAP, $hHBMP))
    _GDIPlus_ImageDispose($hImg)
    _GDIPlus_Shutdown()

GUICtrlCreateInput("Account Name",155,73,120,20)
GUICtrlSetColor(-1, 0x010101)
GUICtrlCreateInput("Password",155,122,120,20,$ES_PASSWORD)
GUICtrlSetColor(-1, 0x010101)
GUICtrlSetOnEvent(-1,"GUI_Close")

_WinAPI_SetLayeredWindowAttributes($hGUISecurityLogin, 0)

GUISetState(@SW_SHOW,$hGUISecurityLogin)

GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN")

EndFunc

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

Func GUI_Close()
    Exit
EndFunc


While 1
    Sleep(10)
WEnd

 

Edited by UEZ
Update

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Looks better now, thanks UEZ ! ;)
All problems gone except one, the Login Button still transparent and shine through background image
But if it's not possible to fix it on an easy way i will simply paint the background in the correct color..

Edited by AndroidZero
Link to comment
Share on other sites

Sorry, I have copied only the function not the full code - updated again.

But yes, for me there is no transparent area in the GUI. Tested on Win10.

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...