Jump to content
Sign in to follow this  

Transparent controls

Recommended Posts

On ‎2008‎年‎6‎月‎8‎日 at 4:26 PM, ChrisL said:

I started messing around with this when someone asked about transparent controls before.

I made a function for creating transparent controls but martin below had a better way of doing it. (Thanks for the help martin!)



It's a great UDF, but I'm having problems with it.
Can you help me with my problem?

Question one

When the GUI is minimized and then restored, you can see that the LISTVIEW location is different


Question two

You can see the pattern of the location of chaos out

So the location will be confused

Look at my pictures

Here is MY CODE

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

   ; GUICreate("LISTVIEW", 220, 250, 100, 200, -1, $WS_EX_ACCEPTFILES)
    GUISetBkColor(0x00E0FFFF) ; 

    Local $idListview = GUICtrlCreateListView("T 1  |T 2|T 3  ", 10, 10, 200, 150) ;,$LVS_SORTDESCENDING)
    Local $idButton = GUICtrlCreateButton("TEST", 75, 170, 70, 20)
    Local $idItem1 = GUICtrlCreateListViewItem("A2|col22|col23", $idListview)
    Local $idItem2 = GUICtrlCreateListViewItem("A1|B2|B3", $idListview)
    Local $idItem3 = GUICtrlCreateListViewItem("A3|col32|col33", $idListview)
    GUICtrlCreateInput("", 20, 200, 150)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED) ;

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE

            Case $idButton

            Case $idListview


Func _GuiCtrlMakeTrans($iCtrlID,$iTrans=255)
    Local $pHwnd, $nHwnd, $aPos, $a
    $hWnd = GUICtrlGetHandle($iCtrlID);Get the control handle
    If $hWnd = 0 then Return SetError(1,1,0) 
    $pHwnd = DllCall("User32.dll", "hwnd", "GetParent", "hwnd", $hWnd);Get the parent Gui Handle
    If $pHwnd[0] = 0 then Return SetError(1,2,0)
    $aPos = ControlGetPos($pHwnd[0],"",$hWnd);Get the current pos of the control
    If @error then Return SetError(1,3,0)
    $nHwnd = GUICreate("", $aPos[2], $aPos[3], $aPos[0], $aPos[1], 0x80000000, 0x00080000 + 0x00000040, $pHwnd[0]);greate a gui in the position of the control
    If $nHwnd = 0 then Return SetError(1,4,0)
    $a = DllCall("User32.dll", "hwnd", "SetParent", "hwnd", $hWnd, "hwnd", $nHwnd);change the parent of the control to the new gui
    If $a[0] = 0 then Return SetError(1,5,0)
    If NOT ControlMove($nHwnd,'',$hWnd,0,0) then Return SetError(1,6,-1);Move the control to 0,0 of the newly created child gui
    GUISetState(@SW_Show,$nHwnd);show the new child gui
    WinSetTrans($nHwnd,"",$iTrans);set the transparency
    If @error then Return SetError(1,7,0)
    GUISwitch($pHwnd[0]);switch back to the parent Gui
    Return $nHwnd;Return the handle for the new Child gui




Edited by kklee69

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...