FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Bug in Transparent Group
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in Transparent Group
Posted: Fri Jan 01, 2010 07:31 PM
Hakan,

You can do it this way:
Code (fw): Select all Collapse
#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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Bug in Transparent Group
Posted: Sat Jan 02, 2010 04:13 AM
May I propose the following change to the EraseBkgnd method of TGroup?
Code (fw): Select all Collapse
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 (fw): Select all Collapse
         SetBrushOrgEx( hDC, -::nLeft, -::nTop )

works exactly the same way as the following code.
Code (fw): Select all Collapse
         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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in Transparent Group
Posted: Sat Jan 02, 2010 09:24 AM
Rao,

If we do:
Code (fw): Select all Collapse
  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 (fw): Select all Collapse
SetBrushOrgEx( hDC, -::nLeft, -::nTop )

thanks! :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: Bug in Transparent Group
Posted: 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 (fw): Select all Collapse
#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.06
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Bug in Transparent Group
Posted: 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
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: Bug in Transparent Group
Posted: Sun Jan 03, 2010 05: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.06

Continue the discussion