Bug in Transparent Group

Re: Bug in Transparent Group

Postby Antonio Linares » Fri Jan 01, 2010 7:31 pm

Hakan,

You can do it this way:
Code: Select all  Expand view
#include 'fivewin.ch'

function Main()

   local oDlg, oGrp

   DEFINE DIALOG oDlg COLOR CLR_WHITE, CLR_BLUE SIZE 600, 400
   
   @ 20, 20 TO 100, 200 PIXEL OF oDlg TRANSPARENT
     
   @ 60, 20 GROUP oGrp TO 100, 200 PIXEL OF oDlg TRANSPARENT
     
   oGrp:bEraseBkGnd = { || nil }  
     
   ACTIVATE DIALOG oDlg CENTER

return nil
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in Transparent Group

Postby nageswaragunupudi » Sat Jan 02, 2010 4:13 am

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.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Bug in Transparent Group

Postby Antonio Linares » Sat Jan 02, 2010 9:24 am

Rao,

If we do:
Code: Select all  Expand view

  if ::oWnd:IsKindOf( 'TDIALOG' )
      return Super:EraseBkGnd( hDC )
  ...
 

then we are calling Class TControl Method EraseBkGnd() which does nothing for DATA lTransparent. No transparency is managed from there, unless I miss something...

Very nice finding for:
Code: Select all  Expand view

SetBrushOrgEx( hDC, -::nLeft, -::nTop )
 

thanks! :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in Transparent Group

Postby Horizon » Sun Jan 03, 2010 12:07 pm

Thanks Antonio,

But I have lots of groups in my app. It will takes lots of time for me.


Antonio Linares wrote:Hakan,

You can do it this way:
Code: Select all  Expand view
#include 'fivewin.ch'

function Main()

   local oDlg, oGrp

   DEFINE DIALOG oDlg COLOR CLR_WHITE, CLR_BLUE SIZE 600, 400
   
   @ 20, 20 TO 100, 200 PIXEL OF oDlg TRANSPARENT
     
   @ 60, 20 GROUP oGrp TO 100, 200 PIXEL OF oDlg TRANSPARENT
     
   oGrp:bEraseBkGnd = { || nil }  
     
   ACTIVATE DIALOG oDlg CENTER

return nil
 
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1288
Joined: Fri May 23, 2008 1:33 pm

Re: Bug in Transparent Group

Postby nageswaragunupudi » Sun Jan 03, 2010 12:35 pm

>>
But I have lots of groups in my app. It will takes lots of time for me.
>>
Better to modify the TGroup class. Not your program code.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Bug in Transparent Group

Postby Horizon » Sun Jan 03, 2010 5:30 pm

Hi Rao,

I have done it since it was changed. But I regularly update fwh every month. I don't want to check it that it was changed or not in every download. I prefer to use unchanged class files from original lib files.

thank anyway.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1288
Joined: Fri May 23, 2008 1:33 pm

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 76 guests