FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Bug in Transparent Group
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Bug in Transparent Group
Posted: Fri Dec 25, 2009 06:38 AM
This is the sample showing the problem
Code (fw): Select all Collapse
#include 'fivewin.ch'

function Main()

   local oWnd

   DEFINE WINDOW oWnd COLOR CLR_WHITE,CLR_BLUE
   @ 20, 20 TO 200,400 PIXEL OF oWnd TRANSPARENT
   ACTIVATE WINDOW oWnd

return nil


This is the result:


Background of the DestkTop is visible through the Group.
Is this a bug or am I doing something wrong?
Regards



G. N. Rao.

Hyderabad, India
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in Transparent Group
Posted: Sat Dec 26, 2009 09:30 PM
Rao,

Class TGroup uses a NULL brush for TRANSPARENT mode and the NULL brush does not work fine under all circunstances.

Please use this workaround which works better:
Code (fw): Select all Collapse
#include 'fivewin.ch'

function Main()

   local oWnd, oGrp

   DEFINE WINDOW oWnd COLOR CLR_WHITE, CLR_BLUE
   
   @ 20, 20 GROUP oGrp TO 200,400 PIXEL OF oWnd // TRANSPARENT
   
   oGrp:SetBrush( oWnd:oBrush )
   
   ACTIVATE WINDOW oWnd

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: Sun Dec 27, 2009 05:00 AM
Mr. Antonio

Thanks.

But when we use image or gradient brush for the window, the background inside the group does not match the background of the window.

The following solution appears to be working ( for windows ), both when resized and brush is changed at runtime.
Code (fw): Select all Collapse
   oGrp:bEraseBkGnd := { |hDC| SetBrushOrgEx( hDC, -oGrp:nLeft, -oGrp:nTop ), ;
        FillRect( hDC, GetClientRect( oGrp:hWnd ), oGrp:oWnd:oBrush:hBrush ) }


Can TGroup include similar code?
Regards



G. N. Rao.

Hyderabad, India
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in Transparent Group
Posted: Sun Dec 27, 2009 09:15 AM
Rao,

Included in FWH 9.12 this way:
Code (fw): Select all Collapse
METHOD EraseBkGnd( hDC ) CLASS TGroup

   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
  
return 0

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 Dec 27, 2009 06:40 PM
Antonio,

Can you try this sample using DIALOG with new EraseBkGnd and without.

Thanks,



Code (fw): Select all Collapse
#include 'fivewin.ch'

function Main()

   local oWnd, cGet := SPACE(15)

   DEFINE DIALOG oWnd COLOR CLR_WHITE,CLR_BLUE SIZE 600,400
   
   @ 20, 20 TO 100,200 PIXEL OF oWnd TRANSPARENT
      
   @ 60, 20 TO 100,200 PIXEL OF oWnd TRANSPARENT
      
   ACTIVATE DIALOG oWnd CENTER

return nil
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: Bug in Transparent Group
Posted: Sun Dec 27, 2009 08:26 PM
Hi,

If I change the method like below it works in dialogs like windows. I don't know it is exactly true.

Code (fw): Select all Collapse
METHOD EraseBkGnd( hDC ) CLASS TGroup

   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   
     if UPPER(::oWnd:ClassName())="TWINDOW"     //added
            FillRect( hDC, GetClientRect( ::hWnd ), ::oWnd:oBrush:hBrush )
     endif //added
  else
     FillRect( hDC, GetClientRect( ::hWnd ), ::oBrush:hBrush )
  endif
  
return 0
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in Transparent Group
Posted: Sun Dec 27, 2009 09:05 PM
Hakan,

Your example works fine here on Windows 7 with the new EraseBkGnd() code:

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: Bug in Transparent Group
Posted: Sun Dec 27, 2009 09:47 PM
Antonio,

You mean it works without any modification. I also use W7. When my example run it show like below.



When my sample lost focus, it is ok.
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: Mon Dec 28, 2009 03:37 AM

On dialogs the previous code also works.

As I said earlier, the modification was necessary only for groups on windows.

Regards



G. N. Rao.

Hyderabad, India
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: Bug in Transparent Group
Posted: Mon Dec 28, 2009 07:42 AM

Hi,

I have no problem with fwh 9.11's TGroup class in dialogs or my modified 9.12 TGroup Class.

Thanks,

Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: Bug in Transparent Group
Posted: Tue Dec 29, 2009 10:49 AM

Antonio ?

Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in Transparent Group
Posted: Tue Dec 29, 2009 04:07 PM

Hakan,

With FWH 9.12 and the posted example, here it works fine on Windows 7.

Please post an example if you have a wrong behavior, thanks

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: Bug in Transparent Group
Posted: Thu Dec 31, 2009 11:25 AM

Hi Antonio,

Unfortunately, my previous example has the same error in my computer. I have the latest fwh 9.12 (I think).

I don't want to change TGroup class everytime that I downloaded fwh. How Can I solve my problem.

Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in Transparent Group
Posted: Thu Dec 31, 2009 02:32 PM

Hakan,

There is a FWH 9.12 31 December build. Please download it and test it.

If there is something wrong, please provide an example to reproduce it, thanks :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: Bug in Transparent Group
Posted: Fri Jan 01, 2010 02:27 PM
Antonio,

Result is the same. my sample is below.

Code (fw): Select all Collapse
#include 'fivewin.ch'


function Main()

   local oWnd

   DEFINE DIALOG oWnd COLOR CLR_WHITE,CLR_BLUE SIZE 600,400
   
   @ 20, 20 TO 100,200 PIXEL OF oWnd TRANSPARENT
      
   @ 60, 20 TO 100,200 PIXEL OF oWnd TRANSPARENT
      
   ACTIVATE DIALOG oWnd CENTER

return nil


First run of app, it has the same error, but when i click outside of the dialog it is OK.
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06