#include "FiveWin.ch"
static oToolBar
function Main()
local oWnd, oImageList, oRadio1, oSay1, oFont
LOCAL nSWidth := GetSysMetrics(0), nSHeight := GetSysMetrics(1)
DEFINE WINDOW oWnd TITLE "FWH - Testing Win32 Toolbars" ;
MENU BuildMenu() MDI
// First we build an ImageList with all the bitmaps
DEFINE IMAGELIST oImageList SIZE 32, 32
DEFINE IMGBITMAP OF oImageList NAME "new" COLOR nRGB( 255, 0, 255 )
DEFINE IMGBITMAP OF oImageList NAME "open" COLOR nRGB( 255, 0, 255 )
DEFINE IMGBITMAP OF oImageList NAME "check" COLOR nRGB( 255, 0, 255 )
DEFINE IMGBITMAP OF oImageList NAME "search" COLOR nRGB( 255, 0, 255 )
DEFINE IMGBITMAP OF oImageList NAME "print" COLOR nRGB( 255, 0, 255 )
DEFINE IMGBITMAP OF oImageList NAME "internet" COLOR nRGB( 255, 0, 255 )
DEFINE IMGBITMAP OF oImageList NAME "keys" COLOR nRGB( 255, 0, 255 )
DEFINE IMGBITMAP OF oImageList NAME "quit" COLOR nRGB( 255, 0, 255 )
// Now we create the toolbar and add the buttons
DEFINE TOOLBAR oToolBar OF oWnd SIZE 50, 200 ; // Width , Height
IMAGELIST oImageList BALLOON // tooltips balloon style
nBtBrush := 3
IF nBtBrush = 1
DEFINE BRUSH oTBrush COLOR 16443068
ENDIF
IF nBtBrush = 2
aGrad := { { 0.5, 16443068, 10899511 }, { 0.5, 10899511, 16443068 } }
hDC = CreateCompatibleDC( oToolbar:GetDC() )
hBmp = CreateCompatibleBitMap( oToolbar:hDC, oToolbar:nWidth, oToolbar:nHeight )
hBmpOld = SelectObject( hDC, hBmp )
GradientFill( hDC, 0, 0, oToolbar:nHeight, oToolbar:nWidth, aGrad, .T. )
oTBrush := TBrush():New( ,,,, hBmp )
oTBrush:Cargo := aGrad
SelectObject( hDC, hBmpOld )
ReleaseDC(hDC)
ENDIF
IF nBtBrush = 3
DEFINE BRUSH oTBrush FILENAME ".\bitmaps\blustone.bmp"
ENDIF
IF nBtBrush = 4
DEFINE IMAGE oTmp FILENAME ".\bitmaps\olga.jpg"
oTBrush := TBrush():new( ,,,, ResizeBmp( oTmp:hBitmap, oToolbar:nWidth, oToolbar:nHeight, .T. ) )
oTmp:End()
ENDIF
oToolbar:oBrush := oTBrush
oToolBar:SetTextRows( 2 )
oFont := TFont():New("Arial",,-16,.F.,.T. ,,,,.F. )
nRadio1 := 1
@ 100, 100 RADIO oRadio1 VAR nRadio1 OF oToolbar ;
ITEMS "&One", "&Two", "T&hree" _3D SIZE 100, 20 PIXEL ;
HELPID 100, 101, 102 ;
ON CHANGE MsgBeep()
AEval( oRadio1:aItems, { | oRad | oRad:lTransparent := .T., ;
oRad:SetFont ( oFont ), ;
oRad:nClrText := 128 } )
@ 100, 220 SAY oSay1 PROMPT "Transparent Text-test" OF oToolbar PIXEL ;
FONT oFont ;
SIZE 200, 20 COLOR 128
oSay1:lTransparent := .T.
DEFINE TBBUTTON OF oToolBar ;
ACTION oToolbar:SetText( 1, "Hello" ) ; // Modify first button text
TOOLTIP "New" ;
PROMPT "&New project" ;
MESSAGE "New"
DEFINE TBBUTTON OF oToolBar ;
ACTION oToolBar:SetChecked( 2, .t. ) ; // Set pressed the second button
TOOLTIP "Open" ;
PROMPT "Open project" ;
MESSAGE "Open"
DEFINE TBSEPARATOR OF oToolBar
DEFINE TBMENU OF oToolBar ;
ACTION MsgInfo( "Menu" ) ;
TOOLTIP "Menu" ;
PROMPT "Menu" ;
MENU BuildPopup()
DEFINE TBBUTTON OF oToolBar ;
ACTION oToolBar:SetChecked( 2, .f. ) ; // MsgInfo( "Search" ) ;
TOOLTIP "Search" ;
PROMPT "Search"
DEFINE TBBUTTON OF oToolBar ;
ACTION MsgInfo( "Print" ) ;
TOOLTIP "Print a report" ;
PROMPT "Print a report"
DEFINE TBSEPARATOR OF oToolBar
DEFINE TBBUTTON OF oToolBar ;
ACTION MsgInfo( "Upgrade" ) ;
TOOLTIP "Search for new versions" ;
PROMPT "Upgrade"
DEFINE TBBUTTON OF oToolBar ;
ACTION MsgInfo( "Users" ) ;
TOOLTIP "Users management" ;
PROMPT "Users"
DEFINE TBSEPARATOR OF oToolBar
DEFINE TBBUTTON OF oToolBar ;
ACTION oWnd:End() ;
TOOLTIP "End Application" ;
PROMPT "Exit"
DEFINE STATUSBAR OF oWnd PROMPT "Toolbars test"
ACTIVATE WINDOW oWnd MAXIMIZED ;
ON INIT WND_BRUSH( 2, .T., 16443068, 10899511, 0.1, , )
oFont:End()
oTBrush:End()
oImageList:End()
return nil
// -------------------
function BuildMenu()
local oMenu
MENU oMenu
MENUITEM "&Project"
MENU
MENUITEM "&New..." ACTION MsgInfo( "New" ) MESSAGE "New"
MENUITEM "&Open..." ACTION MsgInfo( "Open" ) MESSAGE "Open"
SEPARATOR
MENUITEM "&Exit..." ACTION MsgInfo( "End" ) MESSAGE "Exit"
ENDMENU
MENUITEM "&Edit"
MENU
MENUITEM "&Search..." ACTION MsgInfo( "Search" )
MENUITEM "&Print..." ACTION MsgInfo( "Print" )
ENDMENU
MENUITEM "&Utilities"
MENU
MENUITEM "&Disable button..." ACTION oToolBar:EnableButton( 3, .f. )
MENUITEM "&Enable button..." ACTION oToolBar:EnableButton( 3, .t. )
ENDMENU
ENDMENU
return oMenu
// -----------
function BuildPopup()
local oMenu
MENU oMenu POPUP
MENUITEM "One" ACTION MsgInfo( "One" )
MENUITEM "Two" ACTION MsgInfo( "Two" )
MENUITEM "Three" ACTION MsgInfo( "Three" )
ENDMENU
return oMenu
procedure AppSys // XBase++ requirement
return
// ---------------------------------------
FUNCTION WND_BRUSH( nPos, lDirect1, nColor1a, nColor1b, nMove1, cBrush1, cImage1)
LOCAL hDC, oWnd, oBrush, hBmp, hBmpOld , nWidth , nHeight, aRect
IF nPos = 1
DEFINE BRUSH oBrush COLOR nColor1a
WndMain():oWndClient:SetBrush( oBrush )
ENDIF
IF nPos = 2
aColors1 := { { nMove1, nColor1a, nColor1b }, { nMove1, nColor1b, nColor1a } }
GradientFill( WndMain():oWndClient:GetDC(), 0, 0, WndMain():nHeight(), WndMain():nWidth(), aColors1, lDirect1 )
ENDIF
IF nPos = 5 // transparent Brush
aColors1 := { { nMove1, nColor1a, nColor1b }, { nMove1, nColor1b, nColor1a } }
oWnd := oWndMain:oWndClient
aRect := GetClientRect( oWnd:hWnd )
nHeight := If( lDirect1, aRect[ 3 ] - aRect[ 1 ], 1 )
nWidth := if( lDirect1, 1, aRect[ 4 ] - aRect[ 2 ] )
hDC1 := CreateCompatibleDC( oWnd:GetDC() )
hBmp := CreateCompatibleBitMap( oWnd:hDC, nWidth, nHeight )
BmpOld := SelectObject( hDC1, hBmp )
GradientFill( hDC1, 0, 0, nHeight, nWidth, aColors1, lDirect1 )
DeleteObject( oWnd:oBrush:hBrush )
oBrush := TBrush():New( ,,,, hBmp )
oBrush:Cargo := aColors1
SelectObject( hDC1, hBmpOld )
oWnd:ReleaseDC()
oWndBtn:SetBrush( oBrush )
oWnd:SetBrush( oBrush )
AEval( oWnd:aWnd, { |o| o:Refresh() } )
ENDIF
IF nPos = 3
DEFINE BRUSH oBrush FILENAME cBrush
WndMain():oWndClient:SetBrush( oBrush )
ENDIF
IF nPos = 4
DEFINE IMAGE oTmp FILENAME cImage1
oBrush := TBrush():new( ,,,, ResizeBmp( oTmp:hBitmap, oWndMain:nWidth(), oWndMain:nHeight(), .T. ) )
WndMain():oWndClient:SetBrush( oBrush )
oTmp:End()
ENDIF
RETURN NIL