Jump to content

Transparent Picture OVER colored Button


Shocker
 Share

Recommended Posts

No idea? Here is an Example...

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 310, 147, 192, 114)
$Label1 = GUICtrlCreateLabel("", 84, 25, 140, 97)
GUICtrlSetBkColor(-1, 0xFF0000)
$Icon1 = GUICtrlCreateIcon("", -1, 138, 60, 32, 32)
GUICtrlSetImage(-1, "shell32.dll", 32)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

What is to change, that Background from Trash Symbol is also red and not grey?

Link to comment
Share on other sites

Try this:

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

#Region ### START Koda GUI section ### Form=
_GDIPlus_Startup()
$Form1 = GUICreate("Form1", 310, 147, 192, 114)
$Label1 = GUICtrlCreateLabel("", 84, 25, 140, 97)
GUICtrlSetBkColor(-1, 0xFF0000)
;~ $Icon1 = GUICtrlCreateIcon("", -1, 138, 60, 32, 32)
;~ GUICtrlSetImage(-1, "shell32.dll", 32)
$Icon1 = GUICtrlCreatePic("", 138, 60, 32, 32)

$hIcon = _WinAPI_ShellExtractIcon(@SystemDir & '\shell32.dll', 32, 32, 32)
$hBitmap = _GDIPlus_BitmapCreateFromHICON32($hIcon)
$hGDIBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
_GDIPlus_BitmapDispose($hBitmap)
_WinAPI_DestroyIcon($hIcon)
_WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($Icon1), 0x0172, 0, $hGDIBmp)) ;$STM_SETIMAGE = 0x0172, $IMAGE_BITMAP = 0

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            _WinAPI_DeleteObject($hGDIBmp)
            _GDIPlus_Shutdown()
            Exit
    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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

@UEZ

Thx for reply. Wanted test it, but got an error in StructureConstants.au3...

C:\Program Files\AutoIt3\Include\StructureConstants.au3(1820,89) : ERROR: syntax error (illegal character)
        "uint cyIntegral;uint cxIdeal;lparam lParam;uint cxHeader" & ((@OSVersion = "WIN_XP") ?
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
Link to comment
Share on other sites

You need the latest AutoIt version because of additional GDI+ functions and ternary operators.

 

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

Link to comment
Share on other sites

$hIcon = _WinAPI_ExtractIcon("c:\Program Files (x86)\AutoIt3\Aut2Exe\Icons\AutoIt_Main_v10_256x256_RGB-A.ico", 0)
_WinAPI_ExtractIcon
Extracts an icon from the specified executable file, DLL, or icon file.


 #include <WinAPIRes.au3>
_WinAPI_ExtractIcon ( $sIcon, $iIndex [, $fSmall = 0] )


Parameters
$sIcon The name of an executable file, DLL, or icon file from which icons will be extracted. 
$iIndex The 0-based index of the icon to extract. If this value is a negative number, the function extracts
the icon whose resource identifier is equal to the absolute value of $iIndex. 
$fSmall [optional] Specifies whether to extract a small icon, valid values:
    True - Extract a small icon.
    False - Extract a large icon (Default). 

Return Value
Success : the handle to the extracted icon. 
Failure : 0. 

Remarks
When you are finished using the icon, destroy it using the _WinAPI_DestroyIcon() function.

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

Link to comment
Share on other sites

@UEZ

many thx for reply - works excellent! Is this correct, if i use 2 Icons?

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPIShellEx.au3>
#include <WinAPIRes.au3>

Global $ico = "C:\Program Files\AutoIt3\Aut2Exe\Icons"

#Region ### START Koda GUI section ### Form=
_GDIPlus_Startup()
$Form1 = GUICreate("Form1", 310, 147, 192, 114)
$Label1 = GUICtrlCreateLabel("", 84, 25, 140, 97)
GUICtrlSetBkColor(-1, 0xFF0000)
$Icon1 = GUICtrlCreatePic("", 139, 37, 32, 32)
$Icon2 = GUICtrlCreatePic("", 139, 77, 32, 32)


$hIcon = _WinAPI_ExtractIcon($ico & "\AutoIt_Old4.ico", 0)
$hIcon2 = _WinAPI_ExtractIcon($ico & "\AutoIt_Main_v10_48x48_RGB-A.ico", 0)
$hBitmap = _GDIPlus_BitmapCreateFromHICON32($hIcon)
$hBitmap2 = _GDIPlus_BitmapCreateFromHICON32($hIcon2)
$hGDIBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
$hGDIBmp2 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap2)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_BitmapDispose($hBitmap2)
_WinAPI_DestroyIcon($hIcon)
_WinAPI_DestroyIcon($hIcon2)
_WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($Icon2), 0x0172, 0, $hGDIBmp)) ;$STM_SETIMAGE = 0x0172, $IMAGE_BITMAP = 0
_WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($Icon1), 0x0172, 0, $hGDIBmp2)) ;$STM_SETIMAGE = 0x0172, $IMAGE_BITMAP = 0
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            _WinAPI_DeleteObject($hGDIBmp)
            _GDIPlus_Shutdown()
            Exit
    EndSwitch
WEnd
Link to comment
Share on other sites

It looks good. Add a _WinAPI_DeleteObject($hGDIBmp2) before you exit and it will round it up.

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

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...