ข่าว IT ล่าสุด
ถูกใจอย่าลืม Like Fanpage
Transparent From [ VB6 ]
แสดงแล้ว 4080 ครั้ง /
เมษายน 11, 2010, 11:13:35

ICheer_No0M

ออฟไลน์ ( @ITD-TEAM )
กระทู้ : 36
คะแนนขอบคุณ : 0
Form ...

โค๊ด: [Select]
Private Sub Form_Load()
ActiveTransparency Me, True, False, 200, &H0&
'ActiveTransparency [ชื่อ Form], True, False, [ค่าความโปร่งใส 1 - 255], [สีที่ต้องการให้ทะลุ]
End Sub

Module ...

โค๊ด: [Select]
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 bDefaut As Byte, ByVal dwFlags As Long) As Long

Private Const GWL_EXSTYLE As Long = (-20)
Private Const LWA_COLORKEY As Long = &H1
Private Const LWA_Defaut As Long = &H2
Private Const WS_EX_LAYERED As Long = &H80000


Public Function Transparency(ByVal hwnd As Long, Optional ByVal Col As Long = vbBlack, _
Optional ByVal PcTransp As Byte = 255, Optional ByVal TrMode As Boolean = True) As Boolean

Dim DisplayStyle As Long
On Error Resume Next
VoirStyle = GetWindowLong(hwnd, GWL_EXSTYLE)
If DisplayStyle <> (DisplayStyle Or WS_EX_LAYERED) Then
DisplayStyle = (DisplayStyle Or WS_EX_LAYERED)
Call SetWindowLong(hwnd, GWL_EXSTYLE, DisplayStyle)
End If
Transparency = (SetLayeredWindowAttributes(hwnd, Col, PcTransp, IIf(TrMode, LWA_COLORKEY Or LWA_Defaut, LWA_COLORKEY)) <> 0)

If Not Err.Number = 0 Then Err.Clear

End Function


Public Sub ActiveTransparency(M As Form, d As Boolean, F As Boolean, _
T_Transparency As Integer, Optional Color As Long)
Dim B As Boolean
If d And F Then
B = Transparency(M.hwnd, Color, T_Transparency, False)
ElseIf d Then
B = Transparency(M.hwnd, 0, T_Transparency, True)
Else
B = Transparency(M.hwnd, , 255, True)
End If
End Sub

Credit By CkW


Moshi

ออฟไลน์
กระทู้ : 16,996
คะแนนขอบคุณ : 45
it4x สังคมแห่งการเรียนรู้
เมษายน 11, 2010, 11:15:08
VB6 เพิ่งรู้นะเนี่ยว่าทำ Transparent ได้

 

ด้วยฟังค์ชั่น ตอบด่วน คุณสามารถใช้โค๊ดและ เครื่องหมายแสดงอารมณ์ได้ เหมือนการตั้งกระทู้ธรรมดา แต่สามารถทำได้สะดวกกว่า

ระวัง: หัวข้อนี้ไม่มีการอัพเดทมานานถึง 120 วัน

แจ้งเตือน: โพสของคุณจะไม่แสดงจนกว่าผู้ดูแลจะอนุมัติ.
ชื่อ: อีเมล์: