FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Force No Transparency on a BTNBMP
Posts: 883
Joined: Tue Oct 11, 2005 11:57 AM
Force No Transparency on a BTNBMP
Posted: Mon May 05, 2014 07:55 PM
I create an array of 4*5 BTNBMPS in this way

One by One

Code (fw): Select all Collapse
  @ nRow, nCol   BTNBMP oBoton  OF oWnd5  Prompt cPrompt SIZE nAnBoton,nAlBoton PIXEL NOBORDER FONT oFontBold CENTER

    oBoton:lTRANSPARENT:=.F.
    oBoton:cTooltip:=cPrompt

    oBoton:bClrGrad = { | lMouseOver | If( ! lMouseOver,;
        {{ 1, nRGB(210,210,210), nRGB(210,210,210) }, { 1, nRGB(250,  0,  0), nRGB(250,  0,  0) } }, ;
        {{ 1, nRGB(210, 10, 10), nRGB(210, 10, 10) }, { 1, nRGB(250, 50, 50), nRGB(250, 50, 50) } } ) }


Then thru another function I assign or not the JPG image to each BTNBMP

Code (fw): Select all Collapse
 aBoton[x,y]:FreeBitmaps()
           aBoton[x,y]:lTRANSPARENT:=.F.
           If Len(Alltrim(oDbPro:IMAGEN)) > 0
              aBoton[x,y]:hBitmap1  :=  FILoadFromMemory( oDbPro:IMAGEN )
              aBoton[x,y]:hPalette1 := 0
           Endif
           aBoton[x,y]:cCaption:=oDbPro:MINIDESC
           aBoton[x,y]:cTooltip:=oDbPro:PRODUCTO
           aBoton[x,y]:bAction:=bDo
           aBoton[x,y]:refresh()


But they are all transparent, and I don't need them like that.
They are placed on a Window, with gradient fill and no Transparent Clause

Any help will be appreciated

From Chile
Adolfo
;-) Ji,ji,ji... buena la cosa... "all you need is code"

http://www.xdata.cl - Desarrollo Inteligente
----------
Asus TUF F15, 32GB Ram, 2 * 1 TB NVME M.2, GTX 1650
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: Force No Transparency on a BTNBMP
Posted: Tue May 06, 2014 08:58 AM
Adolfo,

BTNBMP uses the background-color, to be defined as TRANSPARENT
I protected the white color of < eye.bmp > with a gray border.





@ 77, 430 BTNBMP oSBtn[6] OF oDlgMain ;
SIZE 65, 16 PIXEL 2007 ; // B / H
NOBORDER ;
PROMPT " S&how" ;
FILENAME c_path1 + "Preview.Bmp" ;
ACTION SHOWEXPORT( oDlgMain ) ;
FONT oFont1 ;
LEFT
oSBtn[6]:bClrGrad = { | lMouseOver | If( ! lMouseOver,;
{ { 0.50, 3067734, 16777215 }, ;
{ 0.50, 16777215, 3067734 } }, ;
{ { 0.50, 3145727, 16777215 }, ;
{ 0.50, 16777215, 3145727 } } ) }
oSBtn[6]:lTransparent := .t.
oSBtn[6]:cToolTip = { "Show" + CRLF + "Export-image","SHOW", 1, CLR_BLACK, 14089979 }
oSBtn[6]:SetColor( 0, )

Only one line needed, to change the BMP :

Transparent !!!
oSBtn[6]:SetFile( c_path1 + "Eye.Bmp", c_path1 + "Eye.Bmp" )

NON TRANSPARENT !!!. I added a border with PIXELFORMER

oSBtn[6]:SetFile( c_path1 + "Eye1.Bmp", c_path1 + "Eye1.Bmp" )

Best regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 883
Joined: Tue Oct 11, 2005 11:57 AM
Re: Force No Transparency on a BTNBMP
Posted: Tue May 06, 2014 01:20 PM

That means oBtn:lTransparent is useless ?

From Chile
Adolfo

;-) Ji,ji,ji... buena la cosa... "all you need is code"

http://www.xdata.cl - Desarrollo Inteligente
----------
Asus TUF F15, 32GB Ram, 2 * 1 TB NVME M.2, GTX 1650
Posts: 883
Joined: Tue Oct 11, 2005 11:57 AM
Re: Force No Transparency on a BTNBMP
Posted: Wed May 07, 2014 08:26 PM

Antonio, Uwe,

How can I modify BTNBMP to use or show bitmaps with no transparency at all.
I can´t tell my clients to modify each and one of the pictures they need to put in the system with a different border color.

Some have green, blue, gray background, others are photos so there's no way to know the color and so far we have 500 pictures.

Any advice will be appreciated.

I thought lTransparent was the solution, but it is useless.

;-) Ji,ji,ji... buena la cosa... "all you need is code"

http://www.xdata.cl - Desarrollo Inteligente
----------
Asus TUF F15, 32GB Ram, 2 * 1 TB NVME M.2, GTX 1650
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: Force No Transparency on a BTNBMP
Posted: Thu May 08, 2014 09:43 AM
Adolfo,

I think, I found the section in BTNPMP

Transparent .T. or .F. is working now



@ 103, 430 BTNBMP oSBtn[6] OF oDlgMain ;
SIZE 65, 16 PIXEL 2007 ; // B / H
NOBORDER ;
PROMPT " S&how" ;
FILENAME c_path1 + "Preview.Bmp" ;
ACTION SHOWEXPORT( oDlgMain ) ;
FONT oFont1 ;
LEFT
oSBtn[6]:bClrGrad = { | lMouseOver | If( ! lMouseOver,;
{ { 0.50, 3067734, 16777215 }, ;
{ 0.50, 16777215, 3067734 } }, ;
{ { 0.50, 3145727, 16777215 }, ;
{ 0.50, 16777215, 3145727 } } ) }
oSBtn[6]:lTransparent := .F. // .T. shows the bitmap transparent
oSBtn[6]:cToolTip = { "Show" + CRLF + "Export-image","SHOW", 1, CLR_BLACK, 14089979 }
oSBtn[6]:SetColor( 0, )
oSBtn[6]:SetFile( c_path1 + "Eye1.Bmp", c_path1 + "Eye1.Bmp" )

METHOD Paint() CLASS TBtnBmp
from line 1150


Code (fw): Select all Collapse
if ! Empty( hBmp )
     if SetAlpha() .and. ::aAlpha[ nBtn ]
          ABPaint( ::hDC, if( ::lAdjust, nAdjust, nBmpLeft+nAdjust), ;
               if( ::lAdjust, nAdjust, nBmpTop+nAdjust ), hBmp, ::nAlphaLevel() )
     else // changes !!!!
          if ::lTransparent // added !!!
               nOldClr = SetBkColor( ::hDC, nRGB( 255, 255, 255 ) )
               TransBmp( hBmp, nBmpWidth, nBmpHeight, nZeroZeroClr, ::hDC,;
                    if( ::lAdjust, nAdjust, nBmpLeft ), ;
                    if( ::lAdjust, nAdjust, nBmpTop ),;
                    if (::lAdjust, ::nWidth, nBmpWidth ) ,;
                    if( ::lAdjust, ::nHeight, nBmpHeight ) )
               SetBkColor( ::hDC, nOldClr )
          else // new !!!
               PALBMPDRAW( ::hDC, if( ::lAdjust, nAdjust, nBmpTop ), ;
                    if( ::lAdjust, nAdjust, nBmpLeft ), hBmp, , ;
                    if (::lAdjust, ::nWidth, nBmpWidth ), ;
                    if( ::lAdjust, ::nHeight, nBmpHeight ) )
          endif
     endif
endif


Best regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Force No Transparency on a BTNBMP
Posted: Thu May 08, 2014 04:08 PM

Adolfo,

You could use Uwe excellent contribution, or alternatively change the color of the pixel 0, 0 in your bitmaps as FWH uses the pixel 0, 0 color to use it as the color to turn transparent. So changing the color of that pixel, will avoid transparency.

Uwe, your change looks great, so we are going to include it in FWH, thanks! :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion