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

怎麼讓form變透明呢?
我在網路上看過~!
~"~卻找不到教學文件
請個位大大指教~!謝謝

2005-11-19 17:43:54 · 1 個解答 · 發問者 ? 3 in 電腦與網際網路 程式設計

1 個解答

以下程式只適用2000以上之版本,把表單變透明

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

Private Sub Command1_Click() ''整個表單(含元件)變透明
Dim I As Long, A As Byte
A = 120 ''透明度 0~255之間 越小越透明
I = GetWindowLong(Me.hWnd, GWL_EXSTYLE)
SetWindowLong Me.hWnd, GWL_EXSTYLE, I Or WS_EX_LAYERED
SetLayeredWindowAttributes Me.hWnd, 120, A, LWA_ALPHA
End Sub

Private Sub Command2_Click() ''整個表單(不含元件)變透空
Dim I As Long

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

2005-11-19 20:12:10 · answer #1 · answered by W.J.S. 7 · 0 0

fedest.com, questions and answers