Sign in to follow this  
Followers 0
arthalita01

(ask) how make semi transparent listview with image and label visible

5 posts in this topic

my first post 

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>
Global $sIn = @SystemDir & "\shell32.dll" ,$IHM

$hGui = GUICreate("", @DesktopWidth, @DesktopHeight, -1, -1, -1)
$bgku = GUICtrlCreatePic(@Systemdir & "\oobe\images\wpakey.jpg", 0, 0,  @DesktopWidth, @DesktopHeight)
GUICtrlSetState(-1, $GUI_DISABLE)
$hGuiPopular = GUICreate("", @DesktopWidth-100, @DesktopHeight-100, -1, -1, BitOR( $WS_POPUP,$WS_BORDER), BitOR($WS_EX_TOPMOST, -1), $hGui)
GUISetBkColor(0x000000)
;WinSetTrans($hGuiPopular,"",220) ;need more transparent
WinSetTrans($hGuiPopular,"",80);0 = clear
$LV = GUICtrlCreateListView("", 25, 25,  @DesktopWidth-150, @DesktopHeight-150, BitOR( $LVS_REPORT,$LVS_EX_DOUBLEBUFFER),0)
GUICtrlSetBkColor(-1, 0x000000)
_GUICtrlListView_SetView($LV, 1)

  $IHM = _WinAPI_ExtractIconEx($sIn, -1, 0, 0, 0)
    For $i = 1 To $IHM
        GUICtrlCreateListViewItem("-" & $i, $LV)
        GUICtrlSetImage(-1, $sIn, -$i, 1)
        GUICtrlSetColor(-1, 0xffffff)
    Next

    GUISetState(@SW_SHOW, $hGuiPopular)
    GUISetState(@SW_SHOW, $hGui)

 While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd

thanks for help

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

If I understood your post correctly then I think this could achieve the desired effect:

Credit goes to user UEZ  [>Source]

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>
Global $sIn = @SystemDir & "\shell32.dll" ,$IHM

$hGui = GUICreate("", @DesktopWidth, @DesktopHeight, -1, -1, Default, $WS_EX_LAYERED)
GUICtrlCreatePic(@Systemdir & "\oobe\images\wpakey.jpg", 0, 0,  @DesktopWidth, @DesktopHeight)
GUICtrlSetState(-1, $GUI_DISABLE)

$hGuiPopular = GUICreate("", @DesktopWidth-100, @DesktopHeight-100, -1, -1, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_MDICHILD, $hGUI)
GUISetBkColor(0x909090, $hGuiPopular)

$LV = GUICtrlCreateListView("", 25, 25,  @DesktopWidth-150, @DesktopHeight-150, $LVS_EX_DOUBLEBUFFER,0)
GUICtrlSetBkColor($LV, 0x909090)
$hLV1 = GUICtrlGetHandle($LV)
_GUICtrlListView_SetExtendedListViewStyle($hLV1, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_FULLROWSELECT, $LVS_EX_TRANSPARENTBKGND))
_GUICtrlListView_SetView($LV, 1)

  $IHM = _WinAPI_ExtractIconEx($sIn, -1, 0, 0, 0)
    For $i = 1 To $IHM
        GUICtrlCreateListViewItem("-" & $i, $LV)
        GUICtrlSetImage(-1, $sIn, -$i, 1)
    Next

    GUISetState(@SW_SHOW, $hGuiPopular)
    GUISetState(@SW_SHOW, $hGui)
_WinAPI_SetLayeredWindowAttributes($hGuiPopular, 0x909090)


 While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
Edited by mpower

Share this post


Link to post
Share on other sites
like that's but but in your script 
background picture broken and i need "semi transparent" not "true transparency" 
sorry for my bad english
 

1656355_10201404815383050_121454031_n.jp

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

It appears that the artifacts or "broken image" is due to a flaw in the GUICtrlCreatePic function. Using GDI+ removes the artifact.

Try this:

#AutoIt3Wrapper_UseX64=n
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#include <StaticConstants.au3>

_GDIPlus_Startup()

Global $sIn = @SystemDir & "\shell32.dll", $IHM
Global $sFile = @Systemdir & "\oobe\images\wpakey.jpg"
Global $hBitmap = _GDIPlus_ScaleImage($sFile, @DesktopWidth, @DesktopHeight)
Global $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)

$hGui = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, Default, $WS_EX_LAYERED)

$iPic = GUICtrlCreatePic("", 0, 0, @DesktopWidth, @DesktopHeight, BitOR($GUI_SS_DEFAULT_PIC, $SS_CENTERIMAGE, $SS_SUNKEN, $WS_BORDER), BitOR($WS_EX_CLIENTEDGE, $WS_EX_STATICEDGE))
$hB = GUICtrlSendMsg($iPic, 0x0172, 0, $hHBitmap)
If $hB Then _WinAPI_DeleteObject($hB)

$hGuiPopular = GUICreate("", @DesktopWidth-100, @DesktopHeight-100, -1, -1, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_MDICHILD, $hGUI)
GUISetBkColor(0x909090, $hGuiPopular)

$LV = GUICtrlCreateListView("", 25, 25,  @DesktopWidth-150, @DesktopHeight-150, $LVS_EX_DOUBLEBUFFER,0)
GUICtrlSetBkColor($LV, 0x909090)
$hLV1 = GUICtrlGetHandle($LV)
_GUICtrlListView_SetExtendedListViewStyle($hLV1, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_FULLROWSELECT, $LVS_EX_TRANSPARENTBKGND))
_GUICtrlListView_SetView($LV, 1)

$IHM = _WinAPI_ExtractIconEx($sIn, -1, 0, 0, 0)
For $i = 1 To $IHM
    GUICtrlCreateListViewItem("-" & $i, $LV)
    GUICtrlSetImage(-1, $sIn, -$i, 1)
Next

GUISetState(@SW_SHOW, $hGui)
GUISetState(@SW_SHOW, $hGuiPopular)

_WinAPI_SetLayeredWindowAttributes($hGuiPopular, 0x909090)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            _GDIPlus_Shutdown()
            Exit
    EndSwitch
WEnd

Func _GDIPlus_ScaleImage($sFile, $iW, $iH, $iInterpolationMode = 7) ;coded by UEZ 2012
    If Not FileExists($sFile) Then Return SetError(1, 0, 0)
    Local $hImage = _GDIPlus_ImageLoadFromFile($sFile)
    If @error Then Return SetError(2, 0, 0)
    Local $hBitmap = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iW, "int", $iH, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0)
    If @error Then Return SetError(3, 0, 0)
    $hBitmap = $hBitmap[6]
    Local $hBmpCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "handle", $hBmpCtxt, "int", $iInterpolationMode)
    _GDIPlus_GraphicsDrawImageRect($hBmpCtxt, $hImage, 0, 0, $iW, $iH)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hBmpCtxt)
    Return $hBitmap
EndFunc   ;==>_GDIPlus_ScaleImage

I still am not fully grasping what sort of effect you are after when you say "semi transparent", could you illustrate using a picture?

 

 

like that's but but in your script 
background picture broken and i need "semi transparent" not "true transparency" 
sorry for my bad english
 

1656355_10201404815383050_121454031_n.jp

 

Edited by mpower

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

1601567_10201408163426749_1748653477_n.j

like that   :sweating:

Edited by arthalita01

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  
Followers 0