Bug in TBtnBmp [Solved]

User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Bug in TBtnBmp [Solved]

Post by Enrico Maria Giordano »

There's something different in the size of the bitmaps painted over bitmap buttons. Please check.

EMG
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Bug in TBtnBmp

Post by Antonio Linares »

Enrico,

Here it seems ok. Could you please provide an example or a screenshot ? thanks :-)
regards, saludos

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

Re: Bug in TBtnBmp

Post by Antonio Linares »

Enrico,

Yes, I got them. Thanks

In FWH 14.04 there is a change in Class TBtnBmp Method Paint, in line 1360:

Code: Select all

   if ! Empty( hBmp )
      if ::lBmpTransparent
         if SetAlpha() .and. ::aAlpha[ nBtn ]
            ABPaint( ::hDC, oBmpRect:nLeft, oBmpRect:nTop, hBmp, ::nAlphaLevel() )
         else
            DrawTransBmp( ::hDc, hBmp, oBmpRect:nTop, oBmpRect:nLeft, oBmpRect:nWidth, oBmpRect:nWidth )
         endif
      else
         PalBmpDraw( ::hDC, oBmpRect:nTop, oBmpRect:nLeft, hBmp, hPal, oBmpRect:nWidth, oBmpRect:nHeight, ;
                     nil, ::lBmpTransparent )
      endif
   endif
In this line please try to add a +1 in nTop and nLeft:

PalBmpDraw( ::hDC, oBmpRect:nTop + 1, oBmpRect:nLeft + 1, hBmp, hPal, oBmpRect:nWidth, oBmpRect:nHeight, ;
nil, ::lBmpTransparent )

thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Bug in TBtnBmp

Post by Enrico Maria Giordano »

Antonio,

no, unfortunately it is not enough. The image is still not centered and the button still miss the border.

EMG
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Bug in TBtnBmp

Post by Antonio Linares »

Enrico,

Just curiosity, have you tried with + 2 ?

It seems to me as those functions are using the coordinates in a different way. We are going to review it, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Bug in TBtnBmp

Post by Enrico Maria Giordano »

Antonio,
Antonio Linares wrote:Enrico,

Just curiosity, have you tried with + 2 ?
Yes. it doesn't make any difference. :-(
Antonio Linares wrote:It seems to me as those functions are using the coordinates in a different way. We are going to review it, thanks
Thank you, my friend!

EMG
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Bug in TBtnBmp

Post by Antonio Linares »

Enrico,

Please change it this way and it should work fine:

Code: Select all

 if ! Empty( hBmp )
      if ::lBmpTransparent
         if SetAlpha() .and. ::aAlpha[ nBtn ]
            ABPaint( ::hDC, oBmpRect:nLeft, oBmpRect:nTop, hBmp, ::nAlphaLevel() )
         else
            DrawTransBmp( ::hDC, hBmp, oBmpRect:nTop, oBmpRect:nLeft, oBmpRect:nWidth, oBmpRect:nWidth )
         endif
      else
            DrawTransBmp( ::hDC, hBmp, oBmpRect:nTop, oBmpRect:nLeft, oBmpRect:nWidth, oBmpRect:nWidth )
      endif
   endif
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Bug in TBtnBmp

Post by Enrico Maria Giordano »

Antonio,
Antonio Linares wrote:Enrico,

Please change it this way and it should work fine:

Code: Select all

 if ! Empty( hBmp )
      if ::lBmpTransparent
         if SetAlpha() .and. ::aAlpha[ nBtn ]
            ABPaint( ::hDC, oBmpRect:nLeft, oBmpRect:nTop, hBmp, ::nAlphaLevel() )
         else
            DrawTransBmp( ::hDC, hBmp, oBmpRect:nTop, oBmpRect:nLeft, oBmpRect:nWidth, oBmpRect:nWidth )
         endif
      else
            DrawTransBmp( ::hDC, hBmp, oBmpRect:nTop, oBmpRect:nLeft, oBmpRect:nWidth, oBmpRect:nWidth )
      endif
   endif
Sorry, no change. The problem seems to be here:

Code: Select all

DrawTransBmp( ::hDC, hBmp, oBmpRect:nTop, oBmpRect:nLeft, oBmpRect:nWidth, oBmpRect:nWidth )
If I change it to this:

Code: Select all

DrawTransBmp( ::hDc, hBmp, oBmpRect:nTop + 1, oBmpRect:nLeft + 1, oBmpRect:nWidth, oBmpRect:nWidth )
the result is better but still different from the previous version. At least, there is no border anymore. How can I get the border back?

EMG
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Bug in TBtnBmp

Post by Antonio Linares »

Enrico,

How do you create the TBtnBm control ? is it from resources ?

Please post here the RC section and the REDEFINE ... code, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Bug in TBtnBmp

Post by Enrico Maria Giordano »

Antonio,

here they are:

Code: Select all

REDEFINE BTNBMP;
         ID 109 OF oDlg;
         RESOURCE "BMP1", NIL, "BMP2";
         ACTION ...

Code: Select all

CONTROL "", 109, "TBtnBmp", WS_CHILD | WS_VISIBLE, 207, 125, 10, 13
EMG
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Bug in TBtnBmp

Post by Antonio Linares »

Enrico,

Could you provide an example without RCs ? thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Bug in TBtnBmp

Post by Enrico Maria Giordano »

Antonio,

yes, here it is:

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    DEFINE DIALOG oDlg;
           SIZE 800, 600

    @ 10, 10 BTNBMP SIZE 20, 20;
             FILE "c:\fwh\bitmaps\open.bmp";
             ADJUST

    ACTIVATE DIALOG oDlg;
             CENTER

    RETURN NIL
EMG
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Bug in TBtnBmp

Post by Antonio Linares »

Enrico,

The bug was in front of our eyes and we were not seing it :-)

DrawTransBmp( ::hDC, hBmp, oBmpRect:nTop, oBmpRect:nLeft, oBmpRect:nWidth, oBmpRect:nWidth )

obviously it has to be this way:

DrawTransBmp( ::hDC, hBmp, oBmpRect:nTop, oBmpRect:nLeft, oBmpRect:nWidth, oBmpRect:nHeight )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Bug in TBtnBmp

Post by Enrico Maria Giordano »

Antonio,

yes, now the bitmaps are centered again, great! Please note that there are more than one place to fix.

Now, how to get the border back? :-)

EMG
Post Reply