Date: 02-16-2022
Return to Index
created by gbSnippets
'You can specify a color which will be transparent, allowing everything
'beneath it to be completely visible. Also, mouse messages will fall
'through the color keyed area.
'In this example, a white circle is drawn on the overlay dialog. White is
'designated as the transparent color, so everything below the white area
'of the overlay is completely visible. But anything under the grey circle
'is simply visible per the alpha setting of the overlay dialog.
'Click in the white circle and you'll see that the main dialog button sees
'the mouse event. But click over the gray circle and you'll see that the
'main dialog buttons does not see the mouse event.
'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 or %LWA_Colorkey)
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
SelectObject(hdc, GetStockObject(%GRAY_BRUSH))
Ellipse hDC, 45,30,120,60 'draw a circle - will be totally transparent
EndPaint hOverlay, PS
End Select
End Function
'gbs_00906
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm