Date: 02-16-2022
Return to Index
created by gbSnippets
'CombineRgn hRgn(2), hRgn(1), hRgn(0), %RGN_OR
'Regions can be simple (rectangle, round) or they can be very complex.
'Make sure you use the %WS_CLIPSIBLINGS , %WS_CLIPCHILDREN styles
'with both the parent dialog and the controls. This will make sure
'Windows clips using the Regions properly.
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "win32api.inc"
#Resource "gbsnippets.pbr"
Global hDlg,hRgn,hButton As Dword
%IDC_Button = 500
Function PBMain () As Long
Dialog New Pixels, 0, "Un-Square Button",300,300,180,150, %WS_OverlappedWindow or %WS_ClipChildren To hDlg
Control Add ImgButton, hDlg, %IDC_Button, "cowgirl", 30,10,100,100, %WS_ClipSiblings
Control Handle hDlg, %IDC_Button To hButton
hRgn = CreateEllipticRgn(20,20,90,90)
SetWindowRgn(hButton, hRgn, %True)
Dialog Show Modal hDlg Call DlgProc
DeleteObject hRgn
End Function
CallBack Function DlgProc() As Long
Select Case Cb.Msg
Case %WM_Command
If Cb.Ctl = %IDC_Button and CB.CtlMsg = %BN_Clicked Then ? "Click"
Case %WM_LButtonDown
If Cb.WParam = %MK_LBUTTON Then SendMessage hDlg, %WM_NCLButtonDown, %HTCaption, ByVal %Null ' force drag
Case %WM_ContextMenu
Dialog End Cb.Hndl
End Select
End Function
'gbs_00916
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm