Welcome Guest [Log In] [Register]
Add Reply
Lỗi không làm form trong suốt được!; Lỗi không làm form trong suốt được!
Topic Started: Nov 12 2010, 01:28 PM (816 Views)
hoaanhsang
Làm trong suốt form

Bạn hãy đặt đoạn code này vào module của form bạn cần làm trong suốt.
Code:

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
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 LWA_ALPHA = &H2&

Public hWnd As Long

Private Sub Transparent(bytOpacity As Byte)
'bytOpacity : có giá trị từ 0-255
bytOpacity = 192 ' variable keeping opacity setting
hWnd = FindWindow("ThunderDFrame", Me.Caption)
Call SetWindowLong(Me.hWnd, GWL_EXSTYLE, GetWindowLong(Me.hWnd, GWL_EXSTYLE) Or WS_EX_LAYERED)
Call SetLayeredWindowAttributes(Me.hWnd, 0, bytOpacity, LWA_ALPHA)
End Sub

Sau đó bạn có thể tạo một nút lệnh, và gọi thủ tục Transparent và truyền giá trị từ 0 đến 255 xem sao.

Chúc bạn thành công.

Posted Image
Posted Image
Edited by hoaanhsang, Nov 12 2010, 01:43 PM.
No Avatar
Administrator
Quote Post Goto Top Offline Profile
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Hỏi đáp về VBA - Macro · Next Topic »
Add Reply