Bug in TBtnBmp [Solved]

Bug in TBtnBmp [Solved]

Postby Enrico Maria Giordano » Fri May 23, 2014 9:35 pm

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

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

Re: Bug in TBtnBmp

Postby Antonio Linares » Sat May 24, 2014 12:45 pm

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: 41205
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in TBtnBmp

Postby Enrico Maria Giordano » Sat May 24, 2014 1:29 pm

Antonio,

screenshots sent. Let me know if you received them.

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

Re: Bug in TBtnBmp

Postby Antonio Linares » Sat May 24, 2014 11:11 pm

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  Expand view
  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
Antonio Linares
Site Admin
 
Posts: 41205
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in TBtnBmp

Postby Enrico Maria Giordano » Sun May 25, 2014 10:07 am

Antonio,

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

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

Re: Bug in TBtnBmp

Postby Antonio Linares » Sun May 25, 2014 10:34 am

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
Antonio Linares
Site Admin
 
Posts: 41205
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in TBtnBmp

Postby Enrico Maria Giordano » Sun May 25, 2014 10:55 am

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
Enrico Maria Giordano
 
Posts: 8243
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in TBtnBmp

Postby Antonio Linares » Tue May 27, 2014 4:07 pm

Enrico,

Please change it this way and it should work fine:

Code: Select all  Expand view
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
Antonio Linares
Site Admin
 
Posts: 41205
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in TBtnBmp

Postby Enrico Maria Giordano » Tue May 27, 2014 5:30 pm

Antonio,

Antonio Linares wrote:Enrico,

Please change it this way and it should work fine:

Code: Select all  Expand view
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  Expand view
DrawTransBmp( ::hDC, hBmp, oBmpRect:nTop, oBmpRect:nLeft, oBmpRect:nWidth, oBmpRect:nWidth )


If I change it to this:

Code: Select all  Expand view
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
Enrico Maria Giordano
 
Posts: 8243
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in TBtnBmp

Postby Antonio Linares » Wed May 28, 2014 7:34 am

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
Antonio Linares
Site Admin
 
Posts: 41205
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in TBtnBmp

Postby Enrico Maria Giordano » Wed May 28, 2014 9:53 am

Antonio,

here they are:

Code: Select all  Expand view
REDEFINE BTNBMP;
         ID 109 OF oDlg;
         RESOURCE "BMP1", NIL, "BMP2";
         ACTION ...


Code: Select all  Expand view
CONTROL "", 109, "TBtnBmp", WS_CHILD | WS_VISIBLE, 207, 125, 10, 13


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

Re: Bug in TBtnBmp

Postby Antonio Linares » Thu May 29, 2014 8:38 pm

Enrico,

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

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

Re: Bug in TBtnBmp

Postby Enrico Maria Giordano » Thu May 29, 2014 10:05 pm

Antonio,

yes, here it is:

Code: Select all  Expand view
#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
Enrico Maria Giordano
 
Posts: 8243
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in TBtnBmp

Postby Antonio Linares » Thu May 29, 2014 11:01 pm

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
Antonio Linares
Site Admin
 
Posts: 41205
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in TBtnBmp

Postby Enrico Maria Giordano » Fri May 30, 2014 8:35 am

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
User avatar
Enrico Maria Giordano
 
Posts: 8243
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Next

Return to Bugs report & fixes / Informe de errores y arreglos

Who is online

Users browsing this forum: No registered users and 6 guests