Page 1 of 6

Bug in TBtnBmp [Solved]

Posted: Fri May 23, 2014 9:35 pm
by Enrico Maria Giordano
There's something different in the size of the bitmaps painted over bitmap buttons. Please check.

EMG

Re: Bug in TBtnBmp

Posted: Sat May 24, 2014 12:45 pm
by Antonio Linares
Enrico,

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

Re: Bug in TBtnBmp

Posted: Sat May 24, 2014 1:29 pm
by Enrico Maria Giordano
Antonio,

screenshots sent. Let me know if you received them.

EMG

Re: Bug in TBtnBmp

Posted: Sat May 24, 2014 11:11 pm
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

Re: Bug in TBtnBmp

Posted: Sun May 25, 2014 10:07 am
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

Re: Bug in TBtnBmp

Posted: Sun May 25, 2014 10:34 am
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

Re: Bug in TBtnBmp

Posted: Sun May 25, 2014 10:55 am
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

Re: Bug in TBtnBmp

Posted: Tue May 27, 2014 4:07 pm
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

Re: Bug in TBtnBmp

Posted: Tue May 27, 2014 5:30 pm
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

Re: Bug in TBtnBmp

Posted: Wed May 28, 2014 7:34 am
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

Re: Bug in TBtnBmp

Posted: Wed May 28, 2014 9:53 am
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

Re: Bug in TBtnBmp

Posted: Thu May 29, 2014 8:38 pm
by Antonio Linares
Enrico,

Could you provide an example without RCs ? thanks

Re: Bug in TBtnBmp

Posted: Thu May 29, 2014 10:05 pm
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

Re: Bug in TBtnBmp

Posted: Thu May 29, 2014 11:01 pm
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 )

Re: Bug in TBtnBmp

Posted: Fri May 30, 2014 8:35 am
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