Bug in TBtnBmp [Solved]

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,

I have a proposal: why not to revert back to the previous btnbmp.prg that used to work very well? What was the reason behind the new changes?

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 btnbmp source code is an old class (it comes with FWH since the very early beginning) and have been experiencing many transformations, so from time to time, we try to simplify and reorganice the code.

Recently Rao worked on it to simplify it, but it seems that still it is not ok. So yes, in the meantime, you could use the previous version and everything should work fine :-)
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,
* Fix: There was a painting error in Class TBtnBmp due to recent changes in
Class TBtnBmp. Now it is ok.
Unfortunately it is not properly fixed. I had to revert to the previous btnbmp.prg again. :-(

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,

I tested them on a ButtonBar and also on GET ... ACTION ... and seemed ok.

If I remember properly you provided here an example, I am going to review it.

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,

I did my tests on FWH\samples\testbtnb.prg. I have just tested it again and seems fine.

Could you please run that example and see if it is fine there for you ? 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,

I just sent you an image showing the problem:

1. There is a black border that wasn't there before

2. The bitmap is not centered in the button anymore

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 black border is painted from here (Class TBtnBmp Method Paint()):

Code: Select all

      if ::lBorder
         WndBox( ::hDC, 0, 0, ::nHeight - 1, ::nWidth - 1 )
      endif
If you do oBtn:lBorder := .F. then you will avoid it (at least for a temporary solution)

Please try it and lets see if the paiting improves, 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, sorry. The border went away, but:

1. it goes back when the mouse is over the button
2. the bitmap is still not centered
3. there is no 3D effect on the button anymore

:-(

EMG
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Bug in TBtnBmp

Post by cnavarro »

Enrico Maria Giordano wrote:Antonio,

no, sorry. The border went away, but:

1. it goes back when the mouse is over the button
2. the bitmap is still not centered
3. there is no 3D effect on the button anymore

:-(

EMG
Antonio, a mi me ocurre lo mismo
Antonio, I so do I
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
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, Cristobal,

The source code for Class TBtnBmp Method Paint() has been evolving along the years and actually is quite messy.

So this morning I decided to reorganize it, to properly structure it and I have found this:

If you replace Method Paint() with this code:

Code: Select all

METHOD Paint() CLASS TBtnBmp

   // local aInfo := ::DispBegin()

   if ::lTransparent
      SetBrushOrgEx( ::hDC, nBmpWidth( ::oWnd:oBrush:hBitmap ) - ::nLeft,;
                     nBmpHeight( ::oWnd:oBrush:hBitmap ) - ::nTop )
      FillRect( ::hDC, GetClientRect( ::hWnd ), ::oWnd:oBrush:hBrush )
   else
      if Empty( ::bClrGrad )
         FillRect( ::hDC, GetClientRect( ::hWnd ), ::oBrush:hBrush )
      else
         if ::aGrad != nil
            GradientFill( ::hDC, 0, 0, ::nHeight, ::nWidth, ::aGrad() )
         endif
      endif   
   endif

   // ::DispEnd( aInfo )

return nil
This way the background is properly filled. Now if you uncomment the calls to DispBegin() and DispEnd() an unexpected border appears at the top and at the left.

So in order to properly fix its painting we first need to know where this is coming from. Please test it and lets try to find why that is happening. 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 »

I don't keep a copy of my changes today, sorry.

But just replace the Method Paint() in Class TBtnBmp and you will see what I mean.

We need to solve this before moving on and reorganize Method Paint()

My plan is to replace it with a much more structured code.
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 »

Ok, can you send me the original btnbmp.prg? I replaced it with the working one. :-)

EMG
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:This way the background is properly filled. Now if you uncomment the calls to DispBegin() and DispEnd() an unexpected border appears at the top and at the left.
I just tried but I don't see any border, with or without the two calls. And, by the way, I don't see the bitmap too, of course.

EMG
Post Reply