;

Transparant Form VB

Module.BAS
Option Explicit
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Declare Function UpdateLayeredWindow Lib "user32" (ByVal hwnd As Long, ByVal hDCDst As Long, pptDst As Any, psize As Any, ByVal hDCSrc As Long, pptSrc As Any, crKey As Long, ByVal pblend As Long, ByVal dwFlags As Long) 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 Const GWL_EXSTYLE = (-20)
Private Const LWA_COLORKEY = &H1
Private Const LWA_ALPHA = &H2
Private Const ULW_COLORKEY = &H1
Private Const ULW_ALPHA = &H2
Private Const ULW_OPAQUE = &H4
Private Const WS_EX_LAYERED = &H80000

Public Function isTransparent(ByVal hwnd As Long) As Boolean
On Error Resume Next
Dim Msg As Long
Msg = GetWindowLong(hwnd, GWL_EXSTYLE)
  If (Msg And WS_EX_LAYERED) = WS_EX_LAYERED Then
       isTransparent = True
  Else
       isTransparent = False
  End If

  If Err Then
       isTransparent = False
  End If
End Function

Public Function MakeTransparent(ByVal hwnd As Long, Perc As Integer) As Long
Dim Msg As Long
On Error Resume Next
  If Perc <> 255 Then
       MakeTransparent = 1
  Else
       Msg = GetWindowLong(hwnd, GWL_EXSTYLE)
       Msg = Msg Or WS_EX_LAYERED
       SetWindowLong hwnd, GWL_EXSTYLE, Msg
       SetLayeredWindowAttributes hwnd, 0, Perc, LWA_ALPHA
       MakeTransparent = 0
  End If

  If Err Then
       MakeTransparent = 2
  End If
End Function

Public Function MakeOpaque(ByVal hwnd As Long) As Long
Dim Msg As Long
On Error Resume Next
Msg = GetWindowLong(hwnd, GWL_EXSTYLE)
Msg = Msg And Not WS_EX_LAYERED
SetWindowLong hwnd, GWL_EXSTYLE, Msg
SetLayeredWindowAttributes hwnd, 0, 0, LWA_ALPHA
MakeOpaque = 0
  If Err Then
       MakeOpaque = 2
  End If
End Function
Form1
Option Explicit
Dim a As Integer

Private Sub Form_Load()
MakeTransparent Me.hwnd, 0
Timer1.Enabled = True
a = 0
End Sub

Private Sub Timer1_Timer()
a = a + 5
  If a <= 600 Then
       MakeTransparent Me.hwnd, a
  Else
       MakeTransparent Me.hwnd, 255
       Timer1.Enabled = False
  End If
End Sub
Komponen ...
Timer1
Enabled = True
Interval = 1

DOWNLOAD SAMPEL

No comments:

Post a Comment

Post Comments


Do you have any suggestions ? Add comment. Do not spam!

Search By Google

About this blog

Vision and Mission
Assist each company to improve efficiency and effectiveness to achieve the objectives to serve clients in a professional, objective and sustainable and provide the best solutions for businesses in solving problems in the procurement of informatics and technology.

Excellence
With support from experts and experienced professionals and geared towards fulfilling the needs of clients who put quality in a cost competitif. We also work as partners culter tailored to your company's corporate and can also provide an applicable and practical advice for clients.

New

 

WELCOME

Welcome to the Thomas IPT Blog - Thank you being here, and hope you come back often. Please surf here and read more about the world of computers and various articles of the world that I experienced. There are many things about, you'll probably find something interesting.

ABOUT ME

Working as a Management Information System Design And Development Operations Accounting. Specializing in the manufacture of Retail Database Desktop Applications, ERP / MRP, KSP / KSU, Warehouse, etc by using VB, SQL, Access, Crystal Report

NAVIGASI

SOCIAL STUFF

Info