Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Feature] Transparent Forms
#1
Difficulty: 1/5
Sides: Client Only
Tested on: MS4
Works for: MS4
Credits: Me Big Grin
Tutorial Type: Copy and Paste No Tweaks Needed
Note to User: If you use this and your form does NOT have a background image, my Moveable Forms feature, and ALL controls on the form will be unusable. (So remember in form load you need to load a picture to the forms .Picture property)

Put this code in Form_Load of the form at the top:
Code:
Call FormTransparent(Me, vbWhite)

Put this in modDatabase under Option Explicit:
Code:
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Public Const GWL_STYLE = (-16)
Public Const GWL_EXSTYLE = (-20)
Public Const WS_EX_LAYERED = &H80000
Public Const LWA_COLORKEY = &H1
Public Const LWA_ALPHA = &H2

Put this at the bottom of modDatabase:
Code:
Public Sub FormTransparent(ByVal CFrm As Form, ByVal Color As ColorConstants)
    
    CFrm.BackColor = Color
    SetWindowLong CFrm.hwnd, GWL_EXSTYLE, GetWindowLong(CFrm.hwnd, GWL_EXSTYLE) Or WS_EX_LAYERED
    SetLayeredWindowAttributes CFrm.hwnd, Color, 0&, LWA_COLORKEY

End Sub
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)