Date: 02-16-2022
Return to Index
created by gbSnippets
'You can control the amount of transparency with which a window is displayed.
'Primary Code:
'There are two basic lines of code that must be modified to make
'a dialog transparent.
'First, add the extended style %WS_Ex_Layered to the dialog when it is created:
Dialog New Pixels, 0, "Layered Window",300,300,200,100, %WS_OverlappedWindow, %WS_Ex_Layered To hDlg
'Second, set the dialog alpha (transparency) level
SetLayeredWindowAttributes(hDlg, 0, 160, %LWA_ALPHA)
'Optionally, a color may be defined which is treated as completely transparent
'wherever it occurs on the dialog.
SetLayeredWindowAttributes(hDlg, %Blue, 160, %LWA_ALPHA or %LWA_Colorkey)
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
Global hDlg as Dword
Function PBMain() As Long
Dialog New Pixels, 0, "Layered Window",300,300,200,100, %WS_OverlappedWindow, %WS_Ex_Layered To hDlg
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Select Case Cb.Msg
Case %WM_InitDialog
SetLayeredWindowAttributes(hDlg, 0, 160, %LWA_ALPHA)
End Select
End Function
'gbs_00702
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm