SHAPE & TRANSPARENT Clause using TsButton

SHAPE & TRANSPARENT Clause using TsButton

Postby reinaldocrespo » Sat Nov 18, 2006 3:55 pm

Hi,

When using the SHAPE clause with TsButton I get an annoying border when the dialog that contains the button has some kind of background color.

Antonio suggested to fix the tsbutton class using FWTransBmp() function and showed the code below as called from FW Tbitmap Class:

Code: Select all  Expand view  RUN
            hBmpOld = SelectObject( ::hDC, ::hBitmap )
            nZeroZeroClr = GetPixel( ::hDC, 0, 0 )
            SelectObject( ::hDC, hBmpOld )
            nOldClr = SetBkColor( ::hDC, nRGB( 255, 255, 255 ) )
            TransBmp( ::hBitmap, ::nWidth(), ::nHeight(), nZeroZeroClr, ::hDC,;
                      ::nX, ::nY, Super:nWidth(), Super:nHeight() )
            SetBkColor( ::hDC, nOldClr )         


Here's an image of the annoying border I'm referring to:
Image

Perhaps someone has already patch Tsbutton to work with transparencies and would like to share the code or show how?


Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Postby reinaldocrespo » Sat Nov 18, 2006 4:56 pm

I get the same ill effect when using TbtnBmp class:

Image

here is the code:
Code: Select all  Expand view  RUN
   REDEFINE BTNBMP aoBtns[ 1 ] ID 170 OF oDlg RESOURCE "Save48" TOOLTIP "Save to Disk" NOBORDER ACTION SavePatient( odbf, oFld )
   REDEFINE BTNBMP aoBtns[ 2 ] ID 240 OF oDlg RESOURCE "Exit48" TOOLTIP "Exit" NOBORDER ACTION odlg:end()
   aoBtns[ 1 ]:ltransparent := .t.
   aoBtns[ 2 ]:ltransparent := .t.


Any ideas?

Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Postby Antonio Linares » Sat Nov 18, 2006 8:10 pm

Reinaldo,

Make this change in Class TBtnBmp:
Code: Select all  Expand view  RUN
   ...
   local hBmpOld, nZeroZeroClr, nOldClr
   ...
   if ::lTransparent
      hBmpOld = SelectObject( ::hDC, ::hBitmap1 )
      nZeroZeroClr = GetPixel( ::hDC, 0, 0 )
      SelectObject( ::hDC, hBmpOld )
      nOldClr = SetBkColor( ::hDC, nRGB( 255, 255, 255 ) )
      TransBmp( ::hBitmap1, nBmpWidth( ::hBitmap1 ), nBmpHeight( ::hBitmap1 ), nZeroZeroClr, ::hDC,;
                If( ::lPressed, 2, 1 ), If( ::lPressed, 2, 1 ),;
                nBmpWidth( ::hBitmap1 ), nBmpHeight( ::hBitmap1 ) )
      SetBkColor( ::hDC, nOldClr )         
   else   
      PalBtnPaint( ::hWnd, ::hBitmap1, ::hPalette1, ::hBitmap2, ::hPalette2,;
                   ::hBitmap3, ::hPalette3, ::lPressed, ::lAdjust, ::lBorder,;
                   ::oPopup != nil, ::nClrPane,  ::cCaption, ::nLayout,;
                   If( ::oFont != nil, ::oFont:hFont, 0 ), ::nClrText, ::hDC )
   endif             

Image
regards, saludos

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

Postby reinaldocrespo » Sat Nov 18, 2006 8:45 pm

Antonio;

Better. But still. The problem is that I have a grading effect on the background.

Code: Select all  Expand view  RUN
      nZeroZeroClr = GetPixel( ::hDC, 0,0 )


Seems to be taking the color information from the top pixel on the dialog and not from where the actual bmp is to be displayed. I tried using ::ntop, ::nleft; but it made it worse.

Any other idea?

Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Postby Antonio Linares » Sat Nov 18, 2006 11:04 pm

Reinaldo,

nZeroZeroClr is the color of the bitmap at 0, 0, used to build a mask to do the transparency.

TransBmp() should paint ok on a gradient. How does it looks ? Please post an image.
regards, saludos

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

Postby reinaldocrespo » Sun Nov 19, 2006 7:14 pm

Antonio;

Thank you so much for your interest and for answering every question.

Below is a screen shoot. Notice how the border around the btnbmp is painted with the pixel color of the first leftmost pixel.

Image

Reinaldo
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Postby Antonio Linares » Sun Nov 19, 2006 9:48 pm

Reinaldo,

How are you painting the gradient ?

Is it a brush ?
regards, saludos

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

Postby reinaldocrespo » Sun Nov 19, 2006 10:01 pm

Yes, it is a brush.

Code: Select all  Expand view  RUN
   DEFINE BRUSH oBrush RESOURCE "Bckg"
   DEFINE DIALOG oDlg NAME ... ;
   ICON oIcon OF oOwner TRANSPARENT BRUSH oBrush



Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Postby Antonio Linares » Sun Nov 19, 2006 10:17 pm

Reinaldo,

Please email me the brush file, thanks
regards, saludos

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

Postby Antonio Linares » Mon Nov 20, 2006 9:29 am

Reinaldo,

Please remove this line from Class TBtnBmp Method Paint():

FillRect( ::hDC, GetClientRect( ::hWnd ), ::oBrush:hBrush )
regards, saludos

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

Postby reinaldocrespo » Mon Nov 20, 2006 2:35 pm

Antonio;

After commenting that line, here is what I get:

Image

Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Postby Antonio Linares » Mon Nov 20, 2006 7:19 pm

Reinaldo,

This should be the right code:
Code: Select all  Expand view  RUN
   if ::lTransparent .and. ! Empty( ::oBrush:hBitmap )
      SetBrushOrgEx( ::hDC, nBmpWidth( ::oBrush:hBitmap ) - ::nLeft, nBmpHeight( ::oBrush:hBitmap ) - ::nTop )
   endif
   FillRect( ::hDC, GetClientRect( ::hWnd ), ::oBrush:hBrush )
regards, saludos

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

Postby reinaldocrespo » Mon Nov 20, 2006 7:27 pm

YES!!!!

Thank you.


Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Pregunta sobre btnbmp

Postby ricardog » Thu Nov 30, 2006 6:49 am

Sr. Linares

Al hacer las correcciones a la clase TbtnBmp, (como ud. le sugiere al sr. reinaldo), los bitmaps los coloca en la parte superior izquierda, ademas de borrar el texto del boton.

Me podria ayudar con este detalle. (tambien utilizo degradados)


Por su atencion gracias
ricardog
 
Posts: 158
Joined: Tue Oct 11, 2005 3:10 pm

Postby Antonio Linares » Thu Nov 30, 2006 7:29 am

Ricardo,

Puedes proporcionar un pequeño ejemplo de como lo haces ? gracias
regards, saludos

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

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 56 guests