Date: 02-16-2022
Return to Index
created by gbSnippets
'Anything you drawing using GDI commands are also transparent
'on a transparent dialog.
Local PS As PaintStruct, hDC As Dword
Local w,h As Long
Select Case Cb.Msg
Case %WM_Paint
'draw on dialog
hDC = BeginPaint(hDlg, PS)
Ellipse hDC, 280,0,300,10 'draw a circle - will be transparent too
EndPaint hDlg, PS
'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, 0, 160, %LWA_ALPHA)
Case %WM_Paint
'draw on dialog
hDC = BeginPaint(hDlg, PS)
Ellipse hDC, 90,10,170,90 'draw a circle - will be transparent too
EndPaint hDlg, PS
Case %WM_Command
If Cb.Ctl Then ? "I'm Alive!"
End Select
End Function
'gbs_00704
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm