English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

http://tw.knowledge.yahoo.com/question/index?qid=1405111917643

可以讓表單透明化
那透明化要怎麼復原呢
而且透明化後會點的到後面的東西耶
有辦法不要點到後面的東西嗎

2005-11-27 13:15:57 · 1 個解答 · 發問者 Anonymous in 電腦與網際網路 程式設計

1 個解答

那個方法是將表單指定顏色的地方透空,不是透明!
Const LWA_COLORKEY = &H1
Const LWA_ALPHA = &H2
Const GWL_EXSTYLE = (-20)
Const WS_EX_LAYERED = &H80000
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Dim C As Long, I As Long
Private Sub Command1_Click() '指定顏色的地方透空
C = Me.BackColor
Me.BackColor = 120
I = GetWindowLong(Me.hWnd, GWL_EXSTYLE)
SetWindowLong Me.hWnd, GWL_EXSTYLE, I Or WS_EX_LAYERED
SetLayeredWindowAttributes Me.hWnd, 120, 0, LWA_COLORKEY ''指定顏色值為120的地方變透空

End Sub

Private Sub Command2_Click() '還原
Dim A As Byte
Me.BackColor = C
A = 255 ''透明度 0~255之間 越小越透明
SetLayeredWindowAttributes Me.hWnd, 0, A, LWA_ALPHA
End Sub

2005-11-27 18:05:36 · answer #1 · answered by W.J.S. 7 · 0 0

fedest.com, questions and answers