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
Sorry, only students may add comments.
Click here for more
information on how you can set up an account.
If you are a Visitor, go ahead and post your reply as a
new comment, and we'll move it here for you
once it's approved. Be sure to use the same name and email address.
This thread is now CLOSED. If you wish to comment, start a NEW discussion in
Access Developer 18.