Date: 02-16-2022
Return to Index
created by gbSnippets
'Anything you drawing using GDI commands are also transparent
'on a transparent dialog. But by using the %LWA_Colorkey flag,
'you can select a color to be totally transparent!
'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
Control Add Button, hDlg, 500, "Push", 20,20,50,50
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local PS As PaintStruct, hDC As DWord
Select Case Cb.Msg
Case %WM_InitDialog
SetLayeredWindowAttributes(hDlg, %White, 160, %LWA_ALPHA or %LWA_Colorkey)
Case %WM_Paint
'draw on dialog
hDC = BeginPaint(hDlg, PS)
Ellipse hDC, 90,10,170,90 'draw a circle - will be totally transparent
EndPaint hDlg, PS
Case %WM_Command
If Cb.Ctl Then ? "I'm Alive!"
End Select
End Function
'gbs_00705
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm