I'm using REDEFINE BUTTONBMP BITMAP "HROK" ..... to place an alpha bitmap on a dialog. When it first displays, it shows a black background in the area which is supposed to be transparent. If I mouseover the button, it then changes to a transparent background. I would also like to have NOBORDER on the button, but that did not work.
Any ideas ?
BUTTONBMP transparency
- TimStone
- Posts: 2955
- Joined: Fri Oct 07, 2005 1:45 pm
- Location: Trabuco Canyon, CA USA
- Has thanked: 25 times
- Been thanked: 2 times
- Contact:
BUTTONBMP transparency
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Re: BUTTONBMP transparency
Hello Tim,
All possible Settings :
There is a transparent-problem, using a Dialog-Image-Background ( doesn't work ).
Gradient, Color and Brush is OK.

Best Regards
Uwe
All possible Settings :
There is a transparent-problem, using a Dialog-Image-Background ( doesn't work ).
Gradient, Color and Brush is OK.

Code: Select all | Expand
//------------------- RESOURCE - TEST -----------------------------------------
FUNCTION D_RESOUR()
local oBtn1, oBtn2, oBtn3
local oBtn4, oBtn5, oBtn6
local oBtn7, oBtn8, oBtn9
local oBtn10, oBtn11, oBtn12, oBtn13, oSay3, oBMP2
DEFINE CURSOR oCursorHand HAND
DEFINE DIALOG oDlg2 RESOURCE "DIALOG1" FONT oDlgFont ;
TRANSPARENT
// Color
// -------
IF nSTYLE = 1
D_COLOR( oDlg2 )
ENDIF
// Style-Brush ( bricks, Borland ... )
// ---------------------------------------
IF nSTYLE = 3
D_BRUSH1( oDlg2 )
ENDIF
// ImageBrush
// ----------------
IF nSTYLE = 4
DB_IMAGE( oDlg2 )
ENDIF
// ----- Transparent NOBORDER ---------
REDEFINE BTNBMP oBtn1 ID 100 OF oDlg2 ;
NOBORDER ;
FILENAME c_path + "\project\" + D_BUTTON1 ;
ACTION MsgAlert( "Button-Click", "Button 1" ) ;
PROMPT "But.1" ;
FONT oButtFont ;
RIGHT
oBtn1:lTransparent := .T.
oBtn1:cTooltip := "Button1"
oBtn1:SetColor( D_TCOLOR, )
REDEFINE BTNBMP oBtn2 ID 110 OF oDlg2 ;
NOBORDER ;
FILENAME c_path + "\project\" + D_BUTTON2 ;
ACTION MsgAlert( "Button-Click", "Button 2" ) ;
PROMPT "But.2" ;
FONT oButtFont ;
LEFT
oBtn2:lTransparent := .T.
oBtn2:cTooltip := "Button2"
oBtn2:SetColor( D_TCOLOR, )
REDEFINE BTNBMP oBtn3 ID 120 OF oDlg2 ;
NOBORDER ;
FILENAME c_path + "\project\" + D_BUTTON3 ;
ACTION MsgAlert( "Button-Click", "Button 3" ) ;
PROMPT "But.3" ;
FONT oButtFont ;
TOP
oBtn3:lTransparent := .T.
oBtn3:cTooltip := "Button3"
oBtn3:SetColor( D_TCOLOR, )
// ----- Transparent BORDER ---------
REDEFINE BTNBMP oBtn4 ID 130 OF oDlg2 ;
FILENAME c_path + "\project\" + D_BUTTON1 ;
ACTION MsgAlert( "Button-Click", "Button 4" ) ;
PROMPT "But.4" ;
FONT oButtFont ;
BOTTOM
oBtn4:lTransparent := .T.
oBtn4:cTooltip := "Button4"
oBtn4:SetColor( D_TCOLOR, )
REDEFINE BTNBMP oBtn5 ID 140 OF oDlg2 ;
FILENAME c_path + "\project\" + D_BUTTON2 ;
ACTION MsgAlert( "Button-Click", "Button 5" ) ;
PROMPT "Centered" ;
FONT oButtFont ;
CENTER
oBtn5:lTransparent := .T.
oBtn5:cTooltip := "Button5"
oBtn5:SetColor( 7138036, )
oBtn5:SetColor( D_TCOLOR, )
REDEFINE BTNBMP oBtn6 ID 150 OF oDlg2 ;
FILENAME c_path + "\project\" + D_BUTTON3 ;
ACTION MsgAlert( "Button-Click", "Button 6" ) ;
PROMPT " "
oBtn6:lTransparent := .T.
oBtn6:cTooltip := "Button6"
oBtn6:SetColor( D_TCOLOR, )
// ----- Style 2007 Transparent NOBORDER --------
REDEFINE BTNBMP oBtn7 ID 200 OF oDlg2 2007 ;
NOBORDER ;
FILENAME c_path + "\project\" + D_BUTTON1 ;
ACTION MsgAlert( "Button-Click", "Button 1" ) ;
PROMPT "But.1" ;
FONT oButtFont ;
RIGHT
oBtn7:cTooltip := "Button1"
oBtn7:SetColor( D_TCOLOR, )
REDEFINE BTNBMP oBtn8 ID 210 OF oDlg2 2007 ;
NOBORDER ;
FILENAME c_path + "\project\" + D_BUTTON2 ;
ACTION MsgAlert( "Button-Click", "Button 2" ) ;
PROMPT "But.2" ;
FONT oButtFont ;
LEFT
oBtn8:cTooltip := "Button2"
oBtn8:SetColor( D_TCOLOR, )
REDEFINE BTNBMP oBtn9 ID 220 OF oDlg2 2007 ;
NOBORDER ;
FILENAME c_path + "\project\" + D_BUTTON3 ;
ACTION MsgAlert( "Button-Click", "Button 3" ) ;
PROMPT "But.3" ;
FONT oButtFont ;
TOP
oBtn9:cTooltip := "Button3"
oBtn9:SetColor( D_TCOLOR, )
// ----- Style 2007 Transparent BORDER --------
REDEFINE BTNBMP oBtn10 ID 230 OF oDlg2 2007 ;
FILENAME c_path + "\project\" + D_BUTTON1 ;
ACTION MsgAlert( "Button-Click", "Button 4" ) ;
PROMPT "But.4" ;
FONT oButtFont ;
BOTTOM
oBtn10:cTooltip := "Button4"
oBtn10:SetColor( D_TCOLOR, )
REDEFINE BTNBMP oBtn11 ID 240 OF oDlg2 2007 ;
FILENAME c_path + "\project\" + D_BUTTON2 ;
ACTION MsgAlert( "Button-Click", "Button 5" ) ;
PROMPT "Centered" ;
FONT oButtFont ;
CENTER
oBtn11:cTooltip := "Button5"
oBtn11:SetColor( 7138036, )
oBtn11:SetColor( D_TCOLOR, )
REDEFINE BTNBMP oBtn12 ID 250 OF oDlg2 2007 ;
FILENAME c_path + "\project\" + D_BUTTON3 ;
ACTION MsgAlert( "Button-Click", "Button 6" )
oBtn12:cTooltip := "Button6"
// --------------
REDEFINE BTNBMP oBtn13 ID 300 OF oDlg2 2007 ;
FILENAME c_path + "\system\stop.bmp" ;
PROMPT "Close" ;
FONT oButtFont ;
ACTION ( lOPEN[3] := .F., oDlg2:End() )
oBtn13:lTransparent := .T.
oBtn13:cTooltip := "Close"
REDEFINE SAY oSay3 PROMPT "Transparent Text" ID 260 OF oDlg2 FONT oButtFont ;
COLOR D_TCOLOR PIXEL transparent adjust
AEval( oDlg2:aControls, { | o | o:oCursor := oCursorHand } )
// YOU can RESIZE the Buttons from Resource at Runtime !!!!
// D_MOVE = Gradient-Color-Position
// ---------------------------------------------------------------------
ACTIVATE DIALOG oDlg2 CENTERED NOWAIT ;
ON INIT ( oDlg2:Move( 100, 470, oDlg2:nWidth, oDlg2:nHeight, .f. ), ;
oBtn1:SetSize( D_BUTTONH * 2, D_BUTTONV * 2, .T. ), ;
oBtn2:SetSize( D_BUTTONH * 2, D_BUTTONV * 2, .T. ), ;
oBtn3:SetSize( D_BUTTONH * 2, D_BUTTONV * 2, .T. ), ;
oBtn4:SetSize( D_BUTTONH * 2, D_BUTTONV * 2, .T. ), ;
oBtn5:SetSize( D_BUTTONH * 2, D_BUTTONV * 2, .T. ), ;
oBtn6:SetSize( D_BUTTONH * 2, D_BUTTONV * 2, .T. ), ;
oBtn7:SetSize( D_BUTTONH * 2, D_BUTTONV * 2, .T. ), ;
oBtn8:SetSize( D_BUTTONH * 2, D_BUTTONV * 2, .T. ), ;
oBtn9:SetSize( D_BUTTONH * 2, D_BUTTONV * 2, .T. ), ;
oBtn10:SetSize( D_BUTTONH * 2, D_BUTTONV * 2, .T. ), ;
oBtn11:SetSize( D_BUTTONH * 2, D_BUTTONV * 2, .T. ), ;
oBtn12:SetSize( D_BUTTONH * 2, D_BUTTONV * 2, .T. ), oDlg2:Refresh() ) ;
ON PAINT ( IIF( nSTYLE = 2, ;
( D_GRADIENT( hDC, oDlg2, .T. ), ;
GradBrush( oDlg2, { { D_MOVE, D_COLOR1, D_COLOR2 },;
{ D_MOVE, D_COLOR2, D_COLOR1 } }, .T. ) ), NIL ), ;
IIF( nSTYLE = 5, DL_IMAGE( hDC, oDlg2 ), NIL ), ;
D_ALPHA( hDC, D_BUTTON1, 55, 430 ), ;
D_ALPHA( hDC, D_BUTTON2, 190, 430 ), ;
D_ALPHA( hDC, D_BUTTON3, 330, 430 ) )
RETURN NIL
// -------------- DIALOG - GRADIENT --------------------
STATIC FUNCTION D_GRADIENT( hDC, oDlg, lDirect )
local aGrad := { { D_MOVE, D_COLOR1, D_COLOR2 }, ;
{ D_MOVE, D_COLOR2, D_COLOR1 } }
IF lDirect = .T.
GradientFill( hDC, 0, 0, oDlg:nHeight, oDlg:nWidth, aGrad, .T. )
ELSE
GradientFill( hDC, 0, 0, oDlg:nHeight, oDlg:nWidth, aGrad, .F. )
ENDIF
RELEASEDC( hDC )
RETURN NIL
// -------------------------------
FUNCTION GradBrush( oDlg, aColors , nDir)
local hDC, hBmp, hBmpOld , nWidth , nHeight, lDir
DEFAULT lDir := .T.
IF nDir = 1
lDir := .T.
ELSE
lDir := .F.
ENDIF
if Empty( oDlg:oBrush:hBitmap )
nHeight := if(lDir,oDlg:nHeight,1)
nWidth := if(lDir,1,oDlg:nWidth)
hDC = CreateCompatibleDC( oDlg:GetDC() )
hBmp = CreateCompatibleBitMap( oDlg:hDC, nWidth, nHeight )
hBmpOld = SelectObject( hDC, hBmp )
GradientFill( hDC, 0, 0, nHeight, nWidth, aColors,lDir )
DeleteObject( oDlg:oBrush:hBrush )
oDlg:oBrush:hBitmap = hBmp
oDlg:oBrush:hBrush = CreatePatternBrush( hBmp )
SelectObject( hDC, hBmpOld )
oDlg:ReleaseDC()
endif
RETURN NIL
// ------------- DIALOG - COLOR ----------------------------------
STATIC FUNCTION D_COLOR( oDlg )
local oCBrush
DEFINE BRUSH oCBrush COLOR D_COLOR1
SET BRUSH OF oDlg TO oCBrush
RELEASE BRUSH oCBrush
RETURN NIL
//----------------- DIALOG - STYLE ----------------
FUNCTION D_BRUSH1( oDlg )
LOCAL oBrush
DEFINE BRUSH oBrush STYLE "BORLAND"
SET BRUSH OF oDlg TO oBrush
RELEASE BRUSH oBrush
RETURN NIL
//------------- IMAGE - BRUSH --------------------
FUNCTION DB_IMAGE( oDlg )
LOCAL oImage
DEFINE BRUSH oImage FILE c_path + "\project\" + D_BRUSH
SET BRUSH OF oDlg TO oImage
RELEASE BRUSH oImage
RETURN NIL
//------------- IMAGE - Background --------------------
STATIC FUNCTION DL_IMAGE( hDC, oDlg )
LOCAL oImage1
LOCAL nWidth := oDlg:nWidth()
LOCAL nHeight := oDlg:nHeight()
DEFINE IMAGE oImage1 FILE c_path + "\project\" + D_LOGO
PalBmpDraw( hDC, 0, 0, oImage1:hBitmap, , nWIDTH, nHEIGHT, , .T. )
oDlg:ReleaseDC()
RETURN NIL
// --------------------------------------------------------------
// Using different BMP's for Focus, pressed, Caption ...
// --------------------------------------------------------------
REDEFINE BTNBMP oBtn ID 300 OF oDlg ;
PROMPT "Help" ;
FONT oBarFont ;
TOP ;
NOBORDER ;
FILENAME c_path + "\system\Info_A.bmp", ;
c_path + "\system\Info_P.bmp", ;
c_path + "\system\Info_D.bmp", ;
c_path + "\system\Info_M.bmp" ;
ACTION ( D_START(), ;
IIF( FILE("ButtonHelp.exe"), Winexec("ButtonHelp.exe" ), MsgAlert("Helpfile : ButtonHep.exe " ;
+ CRLF + "not found !", "ATTENTION") ) )
oBtn:lTransparent := .T.
oBtn:cTooltip := "2. Resource Preview"
oBtn:lBorder := .F.
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.
i work with FW.
If you have any questions about special functions, maybe i can help.
- TimStone
- Posts: 2955
- Joined: Fri Oct 07, 2005 1:45 pm
- Location: Trabuco Canyon, CA USA
- Has thanked: 25 times
- Been thanked: 2 times
- Contact:
Re: BUTTONBMP transparency
Are you saying that BTNBMP will not work properly against an image background ?
Thanks for all of the examples.
Thanks for all of the examples.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Re: BUTTONBMP transparency
Tim
I tested all possible Combinations.
Transparent button on Image-Background didn't work.
It is the same Example from above but with Image.
Maybe a Solution for the Problem ?
The Result with Image-background. Option 2007 works :

With Ribbonbar, I got the same Button-problem.
A Brush-background works :

Not transparent on Image-background :

Best regards
Uwe
I tested all possible Combinations.
Transparent button on Image-Background didn't work.
It is the same Example from above but with Image.
Maybe a Solution for the Problem ?
The Result with Image-background. Option 2007 works :

With Ribbonbar, I got the same Button-problem.
A Brush-background works :

Not transparent on Image-background :

Code: Select all | Expand
#include 'fivewin.ch'
#include 'ribbon.ch'
#include 'Image.ch'
function Main()
local oDlg, oGrp, oBtn, oImg, hDC
DEFINE DIALOG oDlg SIZE 440, 200 // TRANSPARENT
DB_IMAGE( oDlg ) // BMP-brush
// DEFINE IMAGE oImg FILE "backgrd.jpg"
@ 15,50 RBGROUP oGrp PROMPT 'Transparent' SIZE 100,50 // TRANSPARENT
@ 15,120 RBBTN oBtn PROMPT 'Button' SIZE 40, 40 NORMAL;
BITMAP "Video.bmp" TRANSPARENT ROUND
ACTIVATE DIALOG oDlg CENTERED // ;
*ON PAINT( PalBmpDraw( hDC, 0, 0, oImg:hBitmap ) )
return nil
//------------- BMP - BRUSH --------------------
FUNCTION DB_IMAGE( oDlg )
LOCAL oImage
DEFINE BRUSH oImage FILE "Paper.bmp"
SET BRUSH OF oDlg TO oImage
RELEASE BRUSH oImage
RETURN NIL
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.
i work with FW.
If you have any questions about special functions, maybe i can help.
- TimStone
- Posts: 2955
- Joined: Fri Oct 07, 2005 1:45 pm
- Location: Trabuco Canyon, CA USA
- Has thanked: 25 times
- Been thanked: 2 times
- Contact:
Re: BUTTONBMP transparency
I was using BUTTONBMP BITMAP .... and had the problem.
I went to BTNBMP and made it NOBORDER TRANSPARENT and it does work.
I'm using a .BMP image in the resource as a BRUSH and it works.
At least I have it under control now. Thanks.
I went to BTNBMP and made it NOBORDER TRANSPARENT and it does work.
I'm using a .BMP image in the resource as a BRUSH and it works.
At least I have it under control now. Thanks.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: BUTTONBMP transparency
>>
There is a transparent-problem, using a Dialog-Image-Background ( doesn't work ).
Gradient, Color and Brush is OK.
>>
This is the reason, I advise converting image as brush and use it as background instead of painting image in the paint method.
There is a transparent-problem, using a Dialog-Image-Background ( doesn't work ).
Gradient, Color and Brush is OK.
>>
This is the reason, I advise converting image as brush and use it as background instead of painting image in the paint method.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India