Setting transparan form dengan VB6.
It’s different from VB.Net that have form property “Opacity” from value 0 – 100 %.
For Visual basic 6 we must set from code behind like this :
1. Set new module (file .bas)
Private Declare Function GetWindowLongA Lib "user32" (ByVal hwnd As Long, ByVal nIndex As Long) As LongPrivate Declare Function SetWindowLongA Lib "user32" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As LongPrivate Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crey As Byte, ByVal bAlpha As Byte, ByVal dwFlags As Long) As LongPrivate Const GWL_EXSTYLE = (-20)Private Const WS_EX_LAYERED = &H80000Private Const LWA_ALPHA = &H2&Public Function Opacity(Value As Byte, Frm As Form)On Error GoTo ErrorHandlerDim MaxVal As Byte, MinVal As ByteMinVal = 20: MaxVal = 255If Value > MaxVal Then Value = MaxValIf Value < MinVal Then Value = MinValSetWindowLongA Frm.hwnd, GWL_EXSTYLE, GetWindowLongA(Frm.hwnd, GWL_EXSTYLE) Or WS_EX_LAYEREDSetLayeredWindowAttributes Frm.hwnd, 0, Value, LWA_ALPHAErrorHandler: Exit FunctionEnd Function
2. Set on form code when load (file .frm)
Private Sub Form_Load()Opacity 150, MeEnd Sub
3 comments:
Thank You So Much About That So Useful Example
Ok, your welcome. See you again in my other post.
Opacity Meter. Davinor TOM11 is a modern opacity and transmission meter optimized for thin materials like plastic films opacity meter, sheets and papers.
Post a Comment