I added a animated BUTTONBAR to sample METRPLST.prg
The left mouseclick works as a BARSWITCH.
The bar moves in from right to left and reverse.
I'm working on a modified sample, where there will be a defined subbar from the main-bar and more ...



The used BMP's




Replace the MAIN-function with :
Code: Select all | Expand
#include "fivewin.ch"
#include "xbrowse.ch"
#include "metropnl.ch"
static oMetro, oTools, oSBtn[6]
static nClrBack := CLR_GREEN, aRect[4]
static lBarDlg := .F., c_Path, c_Path1, oBarDlg
//----------------------------------------------------------------------------//
FUNCTION MAIN( cParam )
local oWnd, oBar, oMetro, oBrush
local cTitle := "Start"
SET DATE ITALIAN
SET CENTURY ON
oFont := TFont():New("Arial",0,-16,.F.,.T.,0,0,0,.F. )
aRect[3] := GetSysmetrics( 1 ) - 25 // Screen-Height
aRect[4] := GetSysmetrics( 0 ) // Screen-Width
c_path := cFilePath(GetModuleFileName( GetInstance() ) )
lChDir( "../" )
c_path1 := GetCurDir() + "\Bitmaps\AlphaBmp\"
// Msgalert( c_path1)
DEFINE WINDOW oWnd TITLE cTitle STYLE nOr( WS_POPUP, WS_MAXIMIZE );
COLOR CLR_WHITE, CLR_GREEN
oMetro := MakeMetroPanel( oWnd )
DEFINE BRUSH oBrush FILE '..\bitmaps\hires\earth.bmp' RESIZE
oMetro:SetBrush( oBrush )
oBrush:End()
oMetro:bRClicked := { |Row,Col,f,o| IIF( lBarDlg = .F., DLG_OPEN(), DLG_CLOSE() ) }
// oMetro:bRClicked := { |r,c,f,o| msginfo( 'HWND' + NUMTOHEX( oWnd:hWnd, 8 ) ) }
ACTIVATE WINDOW oWnd MAXIMIZED ;
ON INIT ( oMetro:Show(), ;
oWnd:Move( 0, 0, aRect[4], aRect[3], .f. ) , ; // Top, left, width, height
SHOW_DLG(oWnd), oBarDlg:Move( 0, aRect[4], , aRect[3], .f. ) )
oFont:End()
RETURN NIL
//----------------------------------------------------------------------------//
FUNCTION SHOW_DLG(oWnd)
// Top, Left TO Bottom, Width
DEFINE DIALOG oBarDlg FROM 0, aRect[4] - 100 TO aRect[3], aRect[4] OF oWnd PIXEL ;
STYLE nOr( WS_POPUP, WS_VISIBLE )
@ 30, 2 BTNBMP oSBtn[1] OF oBarDlg PIXEL SIZE 40, 55 ;
NOBORDER ;
PROMPT "&Project" + CRLF + "Edit";
FILENAME c_path1 + "Tools.Bmp" ;
ACTION MsgAlert( "Button 1", "Bar-button" ) ;
FONT oFont ;
TOP
oSBtn[1]:lTransparent := .t.
oSBtn[1]:cTooltip := { "Load the" + CRLF + "PROJECT-editor","PROJECT-editor", 1, CLR_BLACK, 14089979 }
oSBtn[1]:SetColor( 16777215, )
@ 80, 2 BTNBMP oSBtn[2] OF oBarDlg PIXEL SIZE 40, 55 ;
NOBORDER ;
PROMPT "&Select" + CRLF + "Image" ;
FILENAME c_path1 + "Paint.Bmp" ;
ACTION MsgAlert( "Button 2", "Bar-button" ) ;
FONT oFont ;
TOP
oSBtn[2]:lTransparent := .t.
oSBtn[2]:cTooltip := { "SELECT / ADD" + CRLF + "a new Image","NEW Image", 1, CLR_BLACK, 14089979 }
oSBtn[2]:SetColor( 16777215, )
@ 150, 2 BTNBMP oSBtn[3] OF oBarDlg PIXEL SIZE 40, 55 ;
NOBORDER ;
PROMPT "&Save" + CRLF + "Hotsp.";
FILENAME c_path1 + "Save1.Bmp" ;
ACTION MsgAlert( "Button 3", "Bar-button" ) ;
FONT oFont ;
TOP
oSBtn[3]:lTransparent := .t.
oSBtn[3]:cTooltip := { "Save ALL" + CRLF + "Image-settings","IMAGE-save", 1, CLR_BLACK, 14089979 }
oSBtn[3]:SetColor( 16777215, )
@ 220, 2 BTNBMP oSBtn[4] OF oBarDlg PIXEL SIZE 40, 55 ;
NOBORDER ;
PROMPT "&Conv." + CRLF + "Image";
FILENAME c_path1 + "Save1.Bmp" ;
ACTION MsgAlert( "Button 4", "Bar-button" ) ;
FONT oFont ;
TOP
oSBtn[4]:lTransparent := .t.
oSBtn[4]:cTooltip := { "Save ALL" + CRLF + "Image-settings","IMAGE-save", 1, CLR_BLACK, 14089979 }
oSBtn[4]:SetColor( 16777215, )
@ 290, 2 BTNBMP oSBtn[5] OF oBarDlg PIXEL SIZE 40, 55 ;
NOBORDER ;
PROMPT "&Exit" ;
FILENAME c_path1 + "Quit.Bmp" ;
ACTION oWnd:End() ;
FONT oFont ;
TOP
oSBtn[5]:lTransparent := .t.
oSBtn[5]:cTooltip := { "EXIT the" + CRLF + "METRO-Demo","EXIT METRO-Demo", 1, CLR_BLACK, 14089979 }
oSBtn[5]:SetColor( 16777215, )
ACTIVATE DIALOG oBarDlg NOWAIT ;
ON INIT ( D_BACKGRD( oBarDlg, 1, 16744448 ) )
RETURN NIL
// ----------------------------------------------------------------------------
FUNCTION DLG_OPEN()
LOCAL nStepL := 0, nLPos := aRect[4]
lBarDlg := .T.
DO WHILE .T.
nStepL := nStepL + 6
IF nStepL > 100
EXIT
ENDIF
INKEY(0.02)
nLPos := aRect[4] - nStepL
oBarDlg:Move( 0, nLPos, , aRect[3], .f. ) // Top, left, width, height
ENDDO
RETURN NIL
// ----------------------------------------------------------------------------
FUNCTION DLG_CLOSE()
LOCAL nStepL := 0, nLPos := aRect[4] - 100
lBarDlg := .F.
DO WHILE .T.
nStepL := nStepL + 6
IF nStepL > 100
EXIT
ENDIF
INKEY(0.02)
nLPos := nLPos + nStepL
oBarDlg:Move( 0, nLPos, , aRect[3], .f. ) // Top, left, width, height
ENDDO
RETURN NIL
// -------- WINDOW / DIALOG - Background ---------------
FUNCTION D_BACKGRD( oDlg, nStyle, nColor1, nColor2, nMove, lDirect, cBrush, cImage )
LOCAL oBrush, hDC, aGrad, oImage
LOCAL aRect := GETCLIENTRECT( oDlg:hWnd )
IF nStyle = 1 // COLOR
DEFINE BRUSH oBrush COLOR nColor1
oDlg:SetBrush( oBrush )
oBrush:End()
ENDIF
IF nStyle = 2 // GRADIENT Brush
aGrad := { { nMove, nColor1, nColor2 }, { nMove, nColor2, nColor1 } }
hDC = CreateCompatibleDC( oDlg:GetDC() )
hBmp = CreateCompatibleBitMap( oDlg:hDC, oDlg:nWidth, oDlg:nHeight )
hBmpOld = SelectObject( hDC, hBmp )
GradientFill( hDC, 0, 0, oDlg:nHeight, oDlg:nWidth, aGrad, lDirect ) // .T: = Vertical
DeleteObject( oDlg:oBrush:hBrush )
oBrush := TBrush():New( ,,,, hBmp )
oBrush:Cargo := aGrad
SelectObject( hDC, hBmpOld )
ReleaseDC(hDC)
oDlg:SetBrush( oBrush )
oBrush:End()
ENDIF
IF nStyle = 3 // BMP-BRUSH
DEFINE BRUSH oBrush FILE c_path1 + cBrush
oDlg:SetBrush( oBrush )
oBrush:End()
ENDIF
IF nStyle = 4 // Image ADJUSTED
IF FILE( c_path1 + cImage )
DEFINE IMAGE oImage FILE c_path1 + cImage
oBrush := TBrush():new( ,,,, ResizeBmp( oImage:hBitmap, aRect[4], aRect[3], .T. ) )
oImage:End()
oDlg:SetBrush( oBrush )
oBrush:End()
ELSE
IF !EMPTY(cImage)
MsgAlert( "File : " + cImage + CRLF + ;
"does not exist" + CRLF + ;
"to show Image !", "ATTENTION" )
ENDIF
ENDIF
ENDIF
Best Regards
Uwe
