要如何寫出可以讓\"Form1視窗變成透明\"
像有些人就可以寫出讓視窗透明的程式碼!
可以告訴我要如何寫出\"設成透明\"的程式碼
2006-02-13 13:09:23 · 3 個解答 · 發問者 ? 6 in 電腦與網際網路 ➔ 程式設計
這是Windows 2000 後的版本所提供的功能 其實就是用於更炫的特效 程式如下
--------------------------------------------------------------------------------
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 crey As Byte, ByVal bAlpha As Byte, _
ByVal dwFlags As Long) As Long
Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_LAYERED = &H80000
Private Const WS_EX_TRANSPARENT = &H20&
Private Const LWA_ALPHA = &H2&
Option Explicit
Private Sub Command1_Click()
Dim lOldStyle As Long
Dim bTrans As Byte
bTrans = 140 '透明度 0~255之間 越小越透明
lOldStyle = GetWindowLong(Me.hwnd, GWL_EXSTYLE)
SetWindowLong Me.hwnd, GWL_EXSTYLE, lOldStyle Or WS_EX_LAYERED
SetLayeredWindowAttributes Me.hwnd, 0, bTrans, LWA_ALPHA
End Sub
2006-02-14 20:36:44 補充:
to:小毛
你可能沒注意到其中有一行寫著:
bTrans = 140 '透明度 0~255之間 越小越透明
其為設定透明程度。
2006-02-13 16:17:15 · answer #1 · answered by 世賢 7 · 0⤊ 0⤋
TO:小毛
visible的屬性,是使元件是否可見,如果設為false,會讓元件隱藏看不見而非透明吧。
2006-02-14 09:08:18 · answer #2 · answered by 上官 5 · 0⤊ 0⤋
Form1.Visible = False
另外樓上大大說的是半透明 並非透明..爾且很吃cpu喔^^
2006-02-14 08:49:25 · answer #3 · answered by 小毛 5 · 0⤊ 0⤋