Missing transparent BTNBMP on Image-background ?

Missing transparent BTNBMP on Image-background ?

Postby ukoenig » Fri Jun 12, 2009 10:55 pm

Hello,

after many tests, I coudn't find a solution, to define
transparent buttons with BTNBMP on a image-background.
It seems, it works only with colors and brushes.

All Tests :
Color :
Image
Gradient :
Image
Style :
Image
Brush :
Image
Image :
Image

A extended version of sample testbtnb.prg for easy testing :
( define nStyle 1 to 5 for different backgrounds )
Copy the prg with a new name to the FWH-sample-directory and
change inside the functions the path for the brush-bmp and image.
You only need to change the number of nStyle for a different test.

To change :
DEFINE BRUSH oImage FILE "Marble.bmp"
DEFINE IMAGE oImage FILE "Background.jpg"

Code: Select all  Expand view

// Testing the FiveWin Class TBtnBmp at a DialogBox from resources

#include "FiveWin.ch"

//----------------------------------------------------------------------------//

function Main()

local oDlg, nStyle, hDC

SET _3DLOOK ON

DEFINE DIALOG oDlg RESOURCE "Main" //   COLOR "N/B"

REDEFINE BTNBMP ID 110 OF oDlg ;
RESOURCE "Yes" ;
NOBORDER ;
ACTION oDlg:End()
 
 REDEFINE BTNBMP ID 120 OF oDlg 2007 ;
RESOURCE "No"

REDEFINE BTNBMP ID 130 OF oDlg 2007 ;
RESOURCE "Cancel" ;
ACTION oDlg:End()
 
oDlg:aControls[ 1 ]:lTransparent = .t.  

// ----- selected Background -------------
// -----------------------------------------------
// 1 = Color
// 2 = Gradient
// 3 = Style
// 4 = Brush
// 5 = Image

nSTYLE := 5
// -----------------------------------------------
// -----------------------------------------------

// Color
// -------
IF nSTYLE = 1
    D_COLOR( oDlg )  
ENDIF

// Style-Brush
// ----------------
IF nSTYLE = 3
    D_BRUSH( oDlg )
ENDIF

// ImageBrush
// ----------------
IF nSTYLE = 4
    DB_IMAGE( oDlg )
ENDIF

ACTIVATE DIALOG oDlg CENTERED ;
ON PAINT ( IIF( nSTYLE = 2, ( D_GRADIENT( hDC, oDlg ), ;
    GradientBrush( oDlg, { { 0.3, 10389063, 16777215 }, ;
      { 0.3, 16777215, 5156778 } }, .T. ), NIL ), ;
    IIF( nSTYLE = 5,    DL_IMAGE( hDC, oDlg ), NIL ) ) )

return nil

// ------------- 1 ) COLOR ----------------------------------

STATIC FUNCTION D_COLOR( oDlg )
local oBrush

DEFINE BRUSH oBrush  COLOR 5156778
SET BRUSH OF oDlg TO oBrush
RELEASE BRUSH oBrush

RETURN NIL

// -------------- 2 ) DIALOG - GRADIENT --------------------

STATIC FUNCTION D_GRADIENT( hDC, oDlg )
local aGrad := { { 0.3, 10389063, 16777215 },{ 0.3, 16777215, 5156778 } }

GradientFill( hDC,  0, 0, oDlg:nHeight, oDlg:nWidth, aGrad, .T. )

RETURN NIL

//----------------- 3 ) STYLE ----------------

FUNCTION D_BRUSH( oDlg )
LOCAL oBrush

DEFINE BRUSH oBrush  STYLE "TILED"  

SET BRUSH OF oDlg TO oBrush
RELEASE BRUSH oBrush

RETURN NIL

//------------- 4 ) IMAGE - BRUSH --------------------

FUNCTION DB_IMAGE( oDlg )
LOCAL oImage

DEFINE BRUSH oImage FILE "Marble.bmp"
SET BRUSH OF oDlg TO oImage
RELEASE BRUSH oImage

RETURN NIL

//------------- 5 ) IMAGE - PICTURE --------------------

FUNCTION DL_IMAGE( hDC, oDlg )
LOCAL oImage

DEFINE IMAGE oImage FILE "Background.jpg"
PalBmpDraw( hDC, 0, 0, oImage:hBitmap, , oDlg:nWidth(), oDlg:nHeight(), , .T. )

RETURN NIL

// ---------------------------------------

FUNCTION GradientBrush( oDlg, aColors , lDir)
local hDC, hBmp, hBmpOld , nWidth , nHeight

DEFAULT lDir := .T.

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
//----------------------------------------------------------------------------//

procedure AppSys  // Xbase++ requirement

return
 


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: Missing transparent BTNBMP on Image-background ?

Postby Rick Lipkin » Fri Jun 12, 2009 11:25 pm

Uwe

What can I say about your determination !!! .. just fyi, I still can not get a transparent say to work on a gradient dialog .. again, like you seem to have discovered .. the transparent say only works with a brush ..


Rick
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Missing transparent BTNBMP on Image-background ?

Postby ukoenig » Sat Jun 13, 2009 12:05 am

Rick,

Image

The code from the screenshot :

Code: Select all  Expand view

//------------------- RESOURCE - TEST 1 -----------------------------------------

FUNCTION DLG_RES1( oWnd )
local oBtn1, oBtn2, oBtn3, oBtn4, oBtn5, oBtn6, oBtn7, oSay3

DEFINE DIALOG oDlg3 RESOURCE "DIALOG1" of oWnd FONT oDlgFont ;
TITLE "Buttons from Resource Transparent" TRANSPARENT

// Color
// -------
IF nSTYLE = 1
      D_COLOR( oDlg3 )  
ENDIF

// Style-Brush
// ----------------
IF nSTYLE = 3
      D_BRUSH( oDlg3 )
ENDIF

// ImageBrush
// ----------------
IF nSTYLE = 4
      DB_IMAGE( oDlg3 )
ENDIF

// -----  Transparent NOBORDER ---------

REDEFINE BTNBMP oBtn1 ID 100 OF oDlg3 ;
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"

REDEFINE BTNBMP oBtn2 ID 110 OF oDlg3 ;
NOBORDER ;
FILENAME c_path + "
\project\" + D_BUTTON1 ;
ACTION MsgAlert( "
Button-Click", "Button 2" ) ;
PROMPT "
But.2" ;
FONT oButtFont ;
LEFT
oBtn2:lTransparent = .t.
oBtn2:cTooltip := "
Button2"

REDEFINE BTNBMP oBtn3 ID 120 OF oDlg3 ;
NOBORDER ;
FILENAME c_path + "
\project\" + D_BUTTON1 ;
ACTION MsgAlert( "
Button-Click", "Button 3" ) ;
PROMPT "
But.3" ;
FONT oButtFont ;
TOP
oBtn3:lTransparent = .t.
oBtn3:cTooltip := "
Button3"

// -----  Transparent BORDER ---------

REDEFINE BTNBMP oBtn4 ID 200 OF oDlg3 ;
FILENAME c_path + "
\project\" + D_BUTTON1 ;
ACTION MsgAlert( "
Button-Click", "Button 4" ) ;
PROMPT "
But.4" ;
FONT oButtFont ;
BOTTOM
oBtn4:lTransparent = .t.  
oBtn4:cTooltip := "
Button4"

REDEFINE BTNBMP oBtn5 ID 210 OF oDlg3 ;
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, )

REDEFINE BTNBMP oBtn6 ID 220 OF oDlg3 ;
FILENAME c_path + "
\project\" + D_BUTTON3 ;
ACTION MsgAlert( "
Button-Click", "Button 6" ) ;
PROMPT "
"
oBtn6:lTransparent = .t.  
oBtn6:cTooltip := "
Button6"

// --------------
     
REDEFINE BTNBMP oBtn7 ID 300 OF oDlg3 2007 ;
FILENAME c_path + "
\system\stop.bmp" ;
PROMPT "
Close" ;
FONT oButtFont ;
ACTION ( lOPEN[3] := .F., oDlg3:End() )
oBtn7:lTransparent = .t.  
oBtn7:cTooltip := "
Close"

REDEFINE SAY oSay3  PROMPT "
Transparent Text" ID 230 OF oDlg3 FONT oSayFont
oSay3:lTransparent = .t.  
oSay3:SetColor( 0, )  // Black

// From Source with Red text
// -------------------------------
// @ 115, 48 SAY oSay1 PROMPT "
Transparent Text" OF oDlg1 SIZE 30, 20 FONT oSayFont;
// COLOR 128 PIXEL  transparent adjust

// nStyle = 2  Gradient / 5 = Image
// D_DIRECT = 1 Horizontal
// D_MOVE = Color-Position
// D_COLOR1 = Color1
// D_COLOR2 = Color2
// ------------------------------

ACTIVATE DIALOG oDlg3 CENTERED  NOWAIT ;
ON INIT oDlg3:Move( 100, 470, 430, 290, .f. ) ;
ON PAINT ( IIF( nSTYLE = 2 .and. D_DIRECT = 1, ;
   ( D_GRADIENT( hDC, oDlg3 ), ;
    GradientBrush( oDlg3, { { D_MOVE, D_COLOR1, D_COLOR2 },;
    { D_MOVE, D_COLOR2, D_COLOR1 } }, .T. ) ), NIL ), ;
    IIF( nSTYLE = 2 .and. D_DIRECT = 2, ;
   ( D_GRADIENT( hDC, oDlg3 ), ;
    GradientBrush( oDlg3, { { D_MOVE, D_COLOR1, D_COLOR2 },;
    { D_MOVE, D_COLOR2, D_COLOR1 } }, .F. ) ), NIL ), ;
    IIF( nSTYLE = 5, DL_IMAGE( hDC, oDlg3 ), NIL ), ;
    D_ALPHA( hDC ) )   // Alpha-Blended-Bmp

RETURN NIL

// -------------- DIALOG - GRADIENT --------------------

STATIC FUNCTION D_GRADIENT( hDC, oDlg )
local aGrad := { { D_MOVE, D_COLOR1, D_COLOR2 }, ;  
     { D_MOVE, D_COLOR2, D_COLOR1 } }    

IF D_DIRECT = 1
   GradientFill( hDC,  0, 0, oDlg:nHeight, oDlg:nWidth, aGrad, .T. )
ENDIF
IF D_DIRECT = 2
   GradientFill( hDC,  0, 0, oDlg:nHeight, oDlg:nWidth, aGrad, .F. )
ENDIF

RETURN NIL

// ------- Function needed for BTNBMP and use of Gradient ------------------------

FUNCTION GradientBrush( oDlg, aColors , lDir)
local hDC, hBmp, hBmpOld , nWidth , nHeight

DEFAULT lDir := .T.

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

// --------- ALPHA-BMP on Dialog --------------------------------------

STATIC FUNCTION D_ALPHA( hDC )
LOCAL oBmp1

DEFINE BITMAP oBmp1 FILENAME c_path + "
\project\" + D_ALPHA
ABPaint( hDC, 13, 200, oBmp1:hBitmap, 220 )

RETURN NIL



Best Regards
Uwe :lol:
Last edited by ukoenig on Sat Jun 13, 2009 12:18 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: Missing transparent BTNBMP on Image-background ?

Postby Rick Lipkin » Sat Jun 13, 2009 12:16 am

Uwe

I will review your example .. I know it has something to do with the NOWAIT .. I am using modal dialogs and generating the text from code .. not from resource.

Rick
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Missing transparent BTNBMP on Image-background ?

Postby ukoenig » Sat Jun 13, 2009 12:24 am

Rick,

I deleted as a test NOWAIT ( I need it, because there are 4 Dialogs open together )
I got the same result ( NOWAIT has nothing to do with the display ).
Color, Brush and Style is defined inside the dialog.
Gradient and Background-image ON PAINT
I work with VISTA.
For testing, maybe it is better, to install XP as well ( sometimes there are different results ) ?

Shows the same screenshot, but from Source ( used functions from the code above ) :

Code: Select all  Expand view

// ----------------- SOURCE - TEST  1 -------------  

FUNCTION DLG_SOUR1( oWnd )
local oBru, oBtn1, oBtn2, oSay1

DEFINE DIALOG oDlg1 SIZE 400, 600 of oWnd FONT oDlgFont ;
TITLE "Buttons from Source Transparent" TRANSPARENT

// Color
// -------
IF nSTYLE = 1
    D_COLOR( oDlg1 )  
ENDIF

// Style-Brush
// ----------------
IF nSTYLE = 3
    D_BRUSH( oDlg1 )
ENDIF

// Brush-Image
// -----------------
IF nSTYLE = 4
    DB_IMAGE( oDlg1 )
ENDIF

// -----  Transparent NOBORDER ---------

@ 3, 4 BTNBMP oBtn1 OF oDlg1 ;
SIZE D_BUTTONH, D_BUTTONV ;
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"

@ 3, 73  BTNBMP oBtn2 OF oDlg1 ;
SIZE D_BUTTONH, D_BUTTONV ;
NOBORDER ;
FILENAME c_path + "
\project\" + D_BUTTON1 ;
ACTION MsgAlert( "
Button-Click", "Button 2" ) ;
PROMPT "
But.2" ;
FONT oButtFont ;
LEFT
oBtn2:lTransparent = .t.
oBtn2:cTooltip := "
Button2"

@ 3, 143  BTNBMP oBtn3 OF oDlg1 ;
SIZE D_BUTTONH, D_BUTTONV ;
NOBORDER ;
FILENAME c_path + "
\project\" + D_BUTTON1 ;
ACTION MsgAlert( "
Button-Click", "Button 3" ) ;
PROMPT "
But.3" ;
FONT oButtFont ;
TOP
oBtn3:lTransparent = .t.
oBtn3:cTooltip := "
Button3"

// -----  Transparent BORDER --------

@ 47, 4  BTNBMP oBtn4 OF oDlg1 ;
SIZE D_BUTTONH, D_BUTTONV ;
FILENAME c_path + "
\project\" + D_BUTTON1 ;
ACTION MsgAlert( "
Button-Click", "Button 4" ) ;
PROMPT "
But.4" ;
FONT oButtFont ;
BOTTOM
oBtn4:lTransparent = .t.  
oBtn4:cTooltip := "
Button4"

@ 47, 73  BTNBMP oBtn5 OF oDlg1 ;
SIZE D_BUTTONH, D_BUTTONV ;
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, )

@ 47, 143  BTNBMP oBtn6 OF oDlg1 ;
SIZE D_BUTTONH, D_BUTTONV ;
FILENAME c_path + "
\project\" + D_BUTTON3 ;
ACTION MsgAlert( "
Button-Click", "Button 6" )
oBtn6:lTransparent = .t.  
oBtn6:cTooltip := "
Button6"

// --------------
     
@ 90, 143 BTNBMP oBtn7 OF oDlg1 2007 ;
SIZE D_BUTTONH, D_BUTTONV ;
FILENAME c_path + "
\system\stop.bmp" ;
PROMPT "
Close" ;
FONT oButtFont ;
ACTION ( lOPEN[1] := .F., oDlg1:End() )
oBtn7:lTransparent = .t.  
oBtn7:cTooltip := "
Close"

@ 115, 48 SAY oSay1 PROMPT "
Transparent Text" OF oDlg1 SIZE 30, 20 FONT oSayFont;
COLOR 128 PIXEL  transparent adjust

ACTIVATE DIALOG oDlg1 CENTERED NOWAIT ;
ON INIT ( oDlg1:Move( 100, 20, 430, 290, .f. ), DisableX(oDlg1, .T.) ) ;
ON PAINT ( IIF( nSTYLE = 2, D_GRADIENT( hDC, oDlg1 ), NIL ), ;
    IIF( nSTYLE = 5,    DL_IMAGE( hDC, oDlg2 ), NIL ), ;
    D_ALPHA( hDC ) )

RETURN NIL

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: Missing transparent BTNBMP on Image-background ?

Postby PeterHarmes » Tue Jun 16, 2009 11:09 am

Uwe,

I'm looking to freshen up my application and quite like the look of your examples you've posted, have you got one of your tools program for the building of a dialog using gradient painting that you wouldnt mind sharing? Sorry for being cheeky, but your xBrowse tools program was very useful and i learned quite a lot about developing the browses from your app.

Thanks in advance

Pete
PeterHarmes
 
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Re: Missing transparent BTNBMP on Image-background ?

Postby ukoenig » Tue Jun 16, 2009 5:46 pm

Hello Pete,

There will be updates of all Tools, adjusted to new functions of FWH 9.05.

A new Tool-package : Buttontools.
You can test BTNBMP with all possible combinations. The Setup-part is just finished.
Resize buttons, Font-selection, any dialog-background, Button-Alpa-bitmap-selection ....

Image
Button-setup :
Image
Multiheader-support in xBrwTools-Update :
Image
Preview :
Image

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: Missing transparent BTNBMP on Image-background ?

Postby PeterHarmes » Wed Jun 17, 2009 8:22 am

Uwe,

Looks good - does your tools program, produce the code for gradient filled dialogs (from resource)?

Regards,

Pete
PeterHarmes
 
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Re: Missing transparent BTNBMP on Image-background ?

Postby ukoenig » Wed Jun 17, 2009 9:06 am

Pete,

for Windows- and Dialog-backgrounds have a look at the Background-tools
( I'm working on a Update as well )

viewtopic.php?f=3&t=14204&p=73178&hilit=tools#p73178

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: Missing transparent BTNBMP on Image-background ?

Postby PeterHarmes » Wed Jun 17, 2009 10:51 am

Uwe,

Where can i get a copy of the tools app - is this an add on that you sell?

Regards,

Pete
PeterHarmes
 
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Re: Missing transparent BTNBMP on Image-background ?

Postby ukoenig » Wed Jun 17, 2009 11:19 am

Pete,

The Download You can find at :

viewtopic.php?f=3&t=13488&p=69183&hilit=background.zip#p69183

Or direct Download :
http://www.pflegeplus.com/fw_downloads/Background1.zip

The new version, i'm working on, will include much more like Folder-tests and a project-database.
It will be possible, that the customer can create all settings by himself.
At prog.-start, the selected settings are used.

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: jair, nageswaragunupudi and 106 guests