How to create a <spec.> Buttonbar 9.04 ( Symbols included )
Posted: Fri May 22, 2009 6:47 pm
Hello,
the answer to Rick for the bar-design ( some calculations needed ) :
The Buttonbar uses Alpha-Blended BMP's !!!

Regards
Uwe
the answer to Rick for the bar-design ( some calculations needed ) :
The Buttonbar uses Alpha-Blended BMP's !!!

Code: Select all | Expand
...
...
DEFINE WINDOW oWnd TITLE "A new Buttonbar" MDI MENU TMenu():New()
SET MESSAGE OF oWnd TO "A new Buttonbar" ;
CENTERED CLOCK KEYBOARD 2007
@ 0, 0 IMAGE oImage SIZE 150, 150 OF oWnd ADJUST
oImage:Progress( .f. )
oImage:LoadBmp( "BACKGROUND.JPG" )
ACTIVATE WINDOW oWnd MAXIMIZED ;
ON INIT B_BAR() ;
ON PAINT ( DRAWBITMAP( hdc, oImage:hbitmap, 0, 0, ;
oWnd:nWidth(), oWnd:nHeight() ) )
RETURN NIL
// ------- You can add Prompts if You like -----------------------
FUNCTION B_BAR()
LOCAL oDlg, oBtn50, oBtn51, oBtn52, oBtn53, oBtn54
LOCAL nWidth := GetSysMetrics(0), nHeight := GetSysMetrics(1)
LOCAL nTop := GetSysMetrics(30)
nStyle = nOR( WS_OVERLAPPED | WS_VISIBLE )
DEFINE DIALOG oDlg FROM 0, 0 TO 100, 100 OF oWnd STYLE nSTYLE PIXEL TRANSPARENT
@ 0, 0 BTNBMP oBtn50 OF oDlg ;
SIZE 32 , 40 ;
FONT oBTFont1 TOP FILENAME "A_Write.bmp" ;
NOBORDER ;
ACTION ( Tools(oWnd) )
oBtn50:lTransparent = .T.
oBtn50:cTooltip := "Background" + CRLF + "Edit"
@ 40, 0 BTNBMP oBtn51 OF oDlg ;
SIZE 32 , 40 ;
FONT oBTFont1 TOP FILENAME "A_Write.bmp" ;
NOBORDER ;
ACTION MAKE_EXE()
oBtn51:lTransparent := .T.
oBtn51:cTooltip := "New EXE-File"
@ 80, 0 BTNBMP oBtn52 OF oDlg ;
SIZE 32 , 40 ;
FONT oBTFont1 TOP FILENAME "A_Image.bmp" ;
NOBORDER ;
ACTION MsgInfo("Hello")
oBtn52:lTransparent := .T.
oBtn52:cTooltip := "Background" + CRLF + "Edit"
@ 120, 0 BTNBMP oBtn53 OF oDlg ;
SIZE 32 , 40 ;
FONT oBTFont1 TOP FILENAME "A_Help.bmp" ;
NOBORDER ;
ACTION IIF( FILE( "BackgrdHelp.exe" ), Winexec("BackgrdHelp.exe"), ;
MsgAlert( "No HelpFile : BackgrdHelp.exe", "Error" ) )
oBtn53:lTransparent := .T.
oBtn53:cTooltip := "Help" + CRLF + "Edit"
@ 160, 0 BTNBMP oBtn54 OF oDlg ;
SIZE 32 , 40 ;
FONT oBTFont1 TOP FILENAME "A_Stop.bmp" ;
NOBORDER ;
ACTION oWnd:End()
oBtn54:lTransparent := .T.
oBtn54:cTooltip := "Quit"
ACTIVATE DIALOG oDlg CENTERED NOWAIT ;
ON INIT oDlg:Move( 20, nWidth - 65, 70, nHeight - 75, .f. ) ;
ON PAINT ( GRADBAR( hDC, oDlg ), ;
GradientBrush( oDlg, { { 0.1, 10389063, 16777215 },{ 0.1, 16777215, 10389063 } }, .F. ) )
RETURN( NIL )
// ------- Fills the Buttons with Gradient-Background ----------
// ------ otherwise the Buttons are displayed with a white Color --
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
// ---------- Fills the Bar with Gradient ---------------------
STATIC FUNCTION GRADBAR( hDC, oDlg )
local aGrad := { { 0.1, 10389063, 16777215 },{ 0.1, 16777215, 10389063 } }
GradientFill( hDC, 0, 0, oDlg:nHeight + 10, oDlg:nWidth, aGrad, .F. )
RETURN NIL
Regards
Uwe
