Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Developer 18 Lessons    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Semi transparent screen
Mischa Graafmans 
    
3 years ago
Hello all

I just found a code online that allows me to set the transparency of the form background making it semi transparent. I use it in combination with the progress bar making it look great.

I am still trying to figure out how the code exactly works, but maybe Richard can make a developer lesson explaining the code :-)

This is module:

Option Compare Database

Public Const GWL_STYLE = (-16)
Public Const GWL_EXSTYLE = (-20)
Public Const LWA_COLORKEY = &H1
Public Const LWA_ALPHA = &H2
Public Const WS_EX_LAYERED = &H80000
Public Declare PtrSafe Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Public Declare PtrSafe Function SetLayeredWindowAttributes Lib "user32.dll" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Public Declare PtrSafe Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

Sub SetTransp(hWnd As Long, Lcolor As Long)
    On Error Resume Next
    Dim TransP As Long
    TransP = GetWindowLong(hWnd, GWL_EXSTYLE)
    TransP = TransP Or WS_EX_LAYERED
    SetWindowLong hWnd, GWL_EXSTYLE, TransP
    SetLayeredWindowAttributes hWnd, Lcolor, 0, LWA_COLORKEY
End Sub

Public Sub SetFormOpacity(frm As Form, sngOpacity As Single, TColor As Long)
Dim IngStyle As Long

IngStyle = GetWindowLong(frm.hWnd, GWL_EXSTYLE)
SetWindowLong frm.hWnd, GWL_EXSTYLE, IngStyle Or WS_EX_LAYERED
SetLayeredWindowAttributes frm.hWnd, TColor, (sngOpacity * 255), LWA_ALPHA
End Sub

And these are the settings of the form:

Private Sub Form_Load()

    DoCmd.Maximize
    
End Sub

Private Sub Form_Open(Cancel As Integer)

    Dim TransP As Long
    Dim OpacityValue As String
    
    Me.Painting = False
    
    SetFormOpacity Me, 0.8, TransP
    
    Me.Painting = True
    
End Sub

As soon as the form opens it gives a semi transparent background that can be adjusted by setting the 2nd variable in: SetFormOpacity

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Developer 18 Lessons.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/2/2026 3:37:28 AM. PLT: 0s