[Tutorial]Vb6 Transparent Form
The title says all, but i will explain i little.
Wat it does is to make the form background transparent but u can see the controls, labels...
Put that in a module:
(Change the Form1.hWnd for ur FormX.hWnd)
Now if u want to make the form transparent.
Put that where u want (better in Form_Load())
And if u want to make the form untransparent.
Where u want or in Form_Unload()
IF I HAVE HELP U +REP TO ME AND CLICK THANKS!!!
(Pls can a mod stick it?)
Wat it does is to make the form background transparent but u can see the controls, labels...
Put that in a module:
Const LWA_ALPHA = &H2
Const GWL_EXSTYLE = (-20)
Const WS_EX_LAYERED = &H80000
Public lngresult As Long
Public Const LWA_COLORKEY = 1
Option Explicit
Public Const SWP_NOMOVE = 2
Public Const SWP_NOSIZE = 1
Public Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
Public Const HWND_TOPMOST = -1
Public Const HWND_NOTOPMOST = -2
Private m_lngRetVal As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Declare Function SetWindowPos Lib "user32" _
(ByVal hWnd As Long, _
ByVal hWndInsertAfter As Long, _
ByVal x As Long, _
ByVal Y As Long, _
ByVal cx As Long, _
ByVal cy As Long, _
ByVal wFlags As Long) As Long
Public Sub maketrans()
lngresult = GetWindowLong(Form1.hWnd, GWL_EXSTYLE)
lngresult = SetWindowLong(Form1.hWnd, GWL_EXSTYLE, lngresult Or WS_EX_LAYERED)
SetLayeredWindowAttributes Form1.hWnd, RGB(255, 255, 255), 128, LWA_COLORKEY 'Change the 255, 255, 255 for the background color that ur 'using (here white), so white will be transparent (ALL things that have white 'background).
End Sub
Public Sub nomaketrans()
SetWindowLong Form1.hWnd, GWL_EXSTYLE, WS_EX_LAYERED
SetLayeredWindowAttributes Form1.hWnd, 255, 255, LWA_ALPHA 'Same Here (U can find LWA_ALPHA on top)
End Sub
Const GWL_EXSTYLE = (-20)
Const WS_EX_LAYERED = &H80000
Public lngresult As Long
Public Const LWA_COLORKEY = 1
Option Explicit
Public Const SWP_NOMOVE = 2
Public Const SWP_NOSIZE = 1
Public Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
Public Const HWND_TOPMOST = -1
Public Const HWND_NOTOPMOST = -2
Private m_lngRetVal As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Declare Function SetWindowPos Lib "user32" _
(ByVal hWnd As Long, _
ByVal hWndInsertAfter As Long, _
ByVal x As Long, _
ByVal Y As Long, _
ByVal cx As Long, _
ByVal cy As Long, _
ByVal wFlags As Long) As Long
Public Sub maketrans()
lngresult = GetWindowLong(Form1.hWnd, GWL_EXSTYLE)
lngresult = SetWindowLong(Form1.hWnd, GWL_EXSTYLE, lngresult Or WS_EX_LAYERED)
SetLayeredWindowAttributes Form1.hWnd, RGB(255, 255, 255), 128, LWA_COLORKEY 'Change the 255, 255, 255 for the background color that ur 'using (here white), so white will be transparent (ALL things that have white 'background).
End Sub
Public Sub nomaketrans()
SetWindowLong Form1.hWnd, GWL_EXSTYLE, WS_EX_LAYERED
SetLayeredWindowAttributes Form1.hWnd, 255, 255, LWA_ALPHA 'Same Here (U can find LWA_ALPHA on top)
End Sub
Now if u want to make the form transparent.
Put that where u want (better in Form_Load())
maketrans
Where u want or in Form_Unload()
nomaketrans
(Pls can a mod stick it?)

CAn u help me?