Date: 02-16-2022
Return to Index
created by gbSnippets
'By placing a transparent dialog over another dialog, you can
'achieve several effects. For example, you can draw on the
'transparent dialog without affecting the underlying dialog.disable
'In this example, an overlay window is placed over the main dialog,
'and underneath it you can see the control that is on the main dialog
'and under the white circle that is drawn on the overlay dialog.
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
Global hDlg, hOverlay As Dword
Function PBMain() As Long
Dialog New Pixels, 0, "Main Window",300,300,265,100, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, 500, "Under", 20,20,50,50
Control Add Button, hDlg, 501, "Not Under", 180,20,75,50
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local PS As PaintStruct, hDC As Dword, h,w As Long
Select Case Cb.Msg
Case %WM_InitDialog
Dialog New Pixels, hDlg, "Overlay Window",0,0,0,0, %WS_Popup Or %WS_Visible, %WS_Ex_Layered To hOverlay
Dialog Show Modeless hOverlay Call OverlayProc
SetLayeredWindowAttributes(hOverlay, %White, 160, %LWA_ALPHA)
Case %WM_Command
If Cb.Ctl = 501 Then ? "I'm Alive!"
Case %WM_Size
Dialog Get Client hDlg To w,h
Dialog Set Size hOverLay, w/2,h
Case %WM_Move
Dialog Set Loc hOverlay, 0,0
End Select
End Function
CallBack Function OverlayProc() As Long
Local PS As PaintStruct, hDC As Dword, h,w As Long
Select Case Cb.Msg
Case %WM_Paint
hDC = BeginPaint(hOverlay, PS)
Ellipse hDC, 0,0,55,55 'draw a circle - will be totally transparent
EndPaint hOverlay, PS
End Select
End Function
'gbs_00706
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm