'-----------------------------'使用说明:'1.新建一个标准exe工程'2.放置1个CommandButton 控件(使用默认名)'3.把下面的代码复制进去就可以了'-----------------------------Option Explicit'Transparancy API'sPrivate Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As LongPrivate Declare Function UpdateLayeredWindow Lib "user32" (ByVal hWnd As Long, ByVal hdcDst As Long, pptDst As Any, psize As Any, ByVal hdcSrc As Long, pptSrc As Any, crKey As Long, ByVal pblend As Long, ByVal dwFlags As Long) As LongPrivate Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As LongPrivate Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As LongPrivate Const GWL_EXSTYLE = (-20)Private Const LWA_COLORKEY = &H1Private Const LWA_ALPHA = &H2Private Const ULW_COLORKEY = &H1Private Const ULW_ALPHA = &H2Private Const ULW_OPAQUE = &H4Private Const WS_EX_LAYERED = &H80000Public Function isTransparent(ByVal hWnd As Long) As BooleanOn Error Resume NextDim Msg As LongMsg = GetWindowLong(hWnd, GWL_EXSTYLE)If (Msg And WS_EX_LAYERED) = WS_EX_LAYERED ThenisTransparent = TrueElseisTransparent = FalseEnd IfIf Err ThenisTransparent = FalseEnd IfEnd FunctionPublic Function MakeTransparent(ByVal hWnd As Long, ByVal Perc As Integer) As LongDim Msg As LongOn Error Resume NextPerc = 100If Perc < 0 Or Perc > 255 ThenMakeTransparent = 1ElseMsg = GetWindowLong(hWnd, GWL_EXSTYLE)Msg = Msg Or WS_EX_LAYEREDSetWindowLong hWnd, GWL_EXSTYLE, MsgSetLayeredWindowAttributes hWnd, 0, Perc, LWA_ALPHAMakeTransparent = 0End IfIf Err ThenMakeTransparent = 2End IfEnd FunctionPublic Function MakeOpaque(ByVal hWnd As Long) As LongDim Msg As LongOn Error Resume NextMsg = GetWindowLong(hWnd, GWL_EXSTYLE)Msg = Msg And Not WS_EX_LAYEREDSetWindowLong hWnd, GWL_EXSTYLE, MsgSetLayeredWindowAttributes hWnd, 0, 0, LWA_ALPHAMakeOpaque = 0If Err ThenMakeOpaque = 2End IfEnd Function'透明Private Sub Command1_Click() MakeTransparent Me.hWnd, 120 '这里的120是透明度,在0~255之间取值End Sub