Force No Transparency on a BTNBMP

Force No Transparency on a BTNBMP

Postby Adolfo » Mon May 05, 2014 7:55 pm

I create an array of 4*5 BTNBMPS in this way

One by One

Code: Select all  Expand view
 @ 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: Select all  Expand view
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, 1 TB NVME M.2, 1 TB SSD, GTX 1650
User avatar
Adolfo
 
Posts: 846
Joined: Tue Oct 11, 2005 11:57 am
Location: Chile

Re: Force No Transparency on a BTNBMP

Postby ukoenig » Tue May 06, 2014 8: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.

Image

Image

@ 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 :lol:
Last edited by ukoenig on Thu May 08, 2014 9:51 am, edited 1 time in total.
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Force No Transparency on a BTNBMP

Postby Adolfo » Tue May 06, 2014 1: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, 1 TB NVME M.2, 1 TB SSD, GTX 1650
User avatar
Adolfo
 
Posts: 846
Joined: Tue Oct 11, 2005 11:57 am
Location: Chile

Re: Force No Transparency on a BTNBMP

Postby Adolfo » Wed May 07, 2014 8: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, 1 TB NVME M.2, 1 TB SSD, GTX 1650
User avatar
Adolfo
 
Posts: 846
Joined: Tue Oct 11, 2005 11:57 am
Location: Chile

Re: Force No Transparency on a BTNBMP

Postby ukoenig » Thu May 08, 2014 9:43 am

Adolfo,

I think, I found the section in BTNPMP

Transparent .T. or .F. is working now

Image

@ 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: Select all  Expand view

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 :lol:
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Force No Transparency on a BTNBMP

Postby Antonio Linares » Thu May 08, 2014 4: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41414
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 34 guests