May I propose the following change to the EraseBkgnd method of TGroup?
- Code: Select all Expand view
METHOD EraseBkGnd( hDC ) CLASS TGroup
if ::oWnd:IsKindOf( 'TDIALOG' )
return Super:EraseBkGnd( hDC )
else
if ! Empty( ::bEraseBkGnd )
return Eval( ::bEraseBkGnd, hDC )
endif
if ::lTransparent
if ! Empty( ::oWnd:oBrush:hBitmap )
SetBrushOrgEx( hDC, nBmpWidth( ::oWnd:oBrush:hBitmap ) - ::nLeft, nBmpHeight( ::oWnd:oBrush:hBitmap ) - ::nTop )
endif
FillRect( hDC, GetClientRect( ::hWnd ), ::oWnd:oBrush:hBrush )
else
FillRect( hDC, GetClientRect( ::hWnd ), ::oBrush:hBrush )
endif
endif
return 0
//----------------------------------------------------------------------------//
With this change, the earlier behavior for dialogs is retained and transparency on windows is improved. This does not break earlier code for transparent groups on dialogs.
I have also found by experimentation that this code
- Code: Select all Expand view
SetBrushOrgEx( hDC, -::nLeft, -::nTop )
works exactly the same way as the following code.
- Code: Select all Expand view
if ! Empty( ::oWnd:oBrush:hBitmap )
SetBrushOrgEx( hDC, nBmpWidth( ::oWnd:oBrush:hBitmap ) - ::nLeft, nBmpHeight( ::oWnd:oBrush:hBitmap ) - ::nTop )
endif
This can be tested and seen to produce the same results on bitmapped and non-bitmapped brushes.
Why can't we adopt the former simpler code?
Still there were some other issues with transparent painting earlier and now, which I shall express in another post.