#include "FiveWin.ch"
function Main()
local oDlg, oBar
DEFINE DIALOG oDlg RESOURCE "Test"
REDEFINE BUTTONBAR oBar ID 100 OF oDlg 2007
ACTIVATE DIALOG oDlg CENTERED
return nil
#include <windows.h>
test DIALOG 0, 0, 186, 94
STYLE DS_MODALFRAME | WS_BORDER | WS_DLGFRAME | WS_POPUP | WS_SYSMENU
FONT 8, "MS Sans Serif"
CAPTION "Test"
BEGIN
CONTROL "", 100, "TBar", 0 | WS_CHILD | WS_VISIBLE | WS_BORDER, 0, 0, 200, 40
DEFPUSHBUTTON "OK", IDOK, 40, 68, 50, 14, WS_VISIBLE
PUSHBUTTON "Cancel", IDCANCEL, 101, 68, 50, 14, WS_VISIBLE
END
#xcommand REDEFINE BUTTONBAR [<oBar>] ;
[ ID <nId> ] ;
[ <of: OF, DIALOG, WINDOW> <oWnd> ] ;
[ SIZE <nWidth>, <nHeight> ];
[ <l2007: 2007, _2007> ] ;
[ <l2010: 2010, _2010> ] ;
[ <l2013: 2013, _2013> ] ;
=> ;
[ <oBar> := ] TBar():Redefine( <nId>, <oWnd>, <nWidth>, <nHeight>,;
<.l2007.>, <.l2010.>, <.l2013.> )
METHOD Redefine( nId, oWnd, nWidth, nHeight, l2007, l2010, l2013 ) CLASS TBar
::Super:Redefine( nId, oWnd )
::nBtnWidth = nWidth
::nBtnHeight = nHeight
::l2007 = l2007
::l2010 = l2010
::l2013 = l2013
::SetGradients()
return Self
METHOD SetGradients() CLASS TBar
do case
case ::l2007
::bClrGrad = { | lInvert | If( ! lInvert,;
{ { 0.25, RGB( 219, 230, 244 ), RGB( 207, 221, 239 ) },;
{ 0.75, RGB( 201, 217, 237 ), RGB( 231, 242, 255 ) } },;
{ { 0.25, RGB( 255, 253, 222 ), RGB( 255, 231, 151 ) }, ;
{ 0.75, RGB( 255, 215, 84 ), RGB( 255, 233, 162 ) } } ) }
case ::l2010
::bClrGrad = { | lInvert | If( ! lInvert,;
{ { 1, RGB( 255, 255, 255 ), RGB( 229, 233, 238 ) } },;
{ { 2/5, RGB( 255, 253, 222 ), RGB( 255, 231, 147 ) },;
{ 3/5, RGB( 255, 215, 86 ), RGB( 255, 231, 153 ) } } ) }
case ::l2013
::bClrGrad = { | lInvert | If( ! lInvert,;
{ { 1, RGB( 255, 255, 255 ), RGB( 255, 255, 255 ) } },;
{ { 1, RGB( 194, 213, 242 ), RGB( 194, 213, 242 ) } } ) }
otherwise
::bClrGrad = { | lInvert | If( ! lInvert,;
{ { 0.25, RGB( 219, 230, 244 ), RGB( 207, 221, 239 ) },;
{ 0.75, RGB( 201, 217, 237 ), RGB( 231, 242, 255 ) } },;
{ { 0.25, RGB( 255, 253, 222 ), RGB( 255, 231, 151 ) }, ;
{ 0.75, RGB( 255, 215, 84 ), RGB( 255, 233, 162 ) } } ) }
endcase
return nil
ON PAINT in the ACTIVATE command.
#include "fivewin.ch"
//----------------------------------------------------------------------------//
#ifdef __XHARBOUR__
#xtranslate BEGINBAR OF <o> => <o>:bInit := \<||
#xcommand ENDBAR => \>
#else
#xtranslate BEGINBAR OF <o> => <o>:bInit := \{||
#xcommand ENDBAR [<*x*>] => return nil; } <x>
#endif
//----------------------------------------------------------------------------//
function Main()
local oDlg, oBar, oFont, oBrw
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-16
DEFINE DIALOG oDlg SIZE 400,400 PIXEL FONT oFont TRUEPIXEL
BEGINBAR OF oDlg
DEFINE BUTTONBAR oBar OF oDlg SIZE 64,32 2007
DEFINE BUTTON OF oBar PROMPT "Top" ACTION oBrw:GoTop()
DEFINE BUTTON OF oBar PROMPT "Bott" ACTION oBrw:GoBottom()
ENDBAR
@ 32,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
DATASOURCE { 1, 2, 3, 4, 5 } NOBORDER
oBrw:CreateFromCode()
ACTIVATE DIALOG oDlg CENTERED
// do NOT use any ON INIT clause for this test
RELEASE FOnt oFont
return nil
//----------------------------------------------------------------------------//
METHOD Activate( bLClicked, bMoved, bPainted, lCentered, ;
bValid, lModal, bInit, bRClicked, bWhen, lResize16, ;
lCenterInWnd ) CLASS TDialog
static nDlgCount := 0
local hActiveWnd, hWnd, bDlgProc
DEFAULT lCentered := .f., lModal := .t., ::hWnd := 0, lResize16 := .f., lCenterInWnd := .f.
DEFAULT bInit := ::bInit // INSERTED NOW
James Bott wrote:Whenever you need to pass lots of variables, you should be using an object. Then you only pass one object and you can change as many variables as you wish in the function or method you are passing to.
Function Main()
Local oCustomer
Local cCustNo:="1007"
oCustomer:= TCustomer():new( cCustNo )
myFunction( oCustomer )
msgInfo( oCustomer:address )
Return nil
FUNCTION MyFunction( oCustomer )
DEFINE DIALOG oDlg .... OF oWnd
REDEFINE GET .... oCustomer:name
REDEFINE GET .... oCustomer:address
DEFINE BUTTONBAR oBar OF oDlg
DEFINE BUTTON .... OF oBar ACTION oCustomer:save()
DEFINE BUTTON ... OF oBar ACTION oCustomer:add()
ACTIVATE oDlg ....
Return nil
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 62 guests