Sample program
- Code: Select all Expand view
- // Using Windows 7 row selection colors in xbrowse
#include 'fivewin.ch'
#include 'xbrowse.ch'
#define MARQSTYLE_HIGHLWIN7 7
function Main()
local oDlg, oBrw, oFont
USE CUSTOMER ALIAS CUST
DEFINE FONT oFont NAME 'Tahoma' SIZE 0, -14
DEFINE DIALOG oDlg SIZE 640,440 PIXEL ;
FONT oFont TITLE 'XBrowse Gradient Rows'
@ 10, 10 XBROWSE oBrw OF oDlg ;
SIZE 300, 200 PIXEL ;
COLUMNS 'First', 'Last', 'Married', 'City' ;
ALIAS 'CUST' NOBORDER CLASS TXbrWin7()
WITH OBJECT oBrw
//
:nMarqueeStyle = MARQSTYLE_HIGHLWIN7 // for Windows 7 style
//
:Married:SetCheck()
WITH OBJECT :First
:AddBitmap( "c:\fwh\bitmaps\16x16\zoom2.bmp" )
:bBmpData := { || 1 }
END
WITH OBJECT :Last
:AddBitmap( "c:\fwh\bitmaps\16x16\open.bmp" )
:bBmpData := { || 1 }
END
END
oBrw:CreateFromCode()
ACTIVATE DIALOG oDlg CENTERED
oFont:End()
return nil
//----------------------------------------------------------------------------//
CLASS TXbrWin7 FROM TXBrowse
CLASSDATA lRegistered AS LOGICAL // This is compulsory for derived classes
METHOD Adjust()
METHOD FullPaint() INLINE ( ::lTransparent .or. ::lMergeVert .or. ::nMarqueeStyle == MARQSTYLE_HIGHLWIN7 )
METHOD DrawLine( lSelected, nRowSel )
ENDCLASS
//----------------------------------------------------------------------------//
METHOD Adjust() CLASS TXBrWin7
if ::nMarqueeStyle == MARQSTYLE_HIGHLWIN7
::nRowDividerStyle := LINESTYLE_NOLINES
::nColDividerStyle := LINESTYLE_NOLINES
::bClrSelFocus := ;
::bClrSel := { || { CLR_BLACK, ;
{ { 1, RGB( 220, 235, 252 ), ;
RGB( 193, 219, 252 ) } } } }
endif
return Super:Adjust()
//----------------------------------------------------------------------------//
METHOD DrawLine( lSelected, nRowSel ) CLASS TXBrWin7
local hDC, nRow, nBrwWidth, nDataHeight
Super:DrawLine( lSelected, nRowSel )
DEFAULT lSelected := .f.
if lSelected
if ::nMarqueeStyle == MARQSTYLE_HIGHLWIN7
hDC := ::GetDC()
nRow := ( ( ::nRowSel - 1 ) * ::nRowHeight ) + ::HeaderHeight()
nBrwWidth := ::BrwWidth()
nDataHeight := ::DataHeight()
RoundBox( hDC, 2, nRow - 1, nBrwWidth - 1, nRow + nDataHeight, 2, 2,;
RGB( 235, 244, 253 ), 1 )
RoundBox( hDC, 1, nRow - 2, nBrwWidth, nRow + nDataHeight + 1, 2, 2,;
RGB( 125, 162, 206 ), 1 )
endif
endif
return Self
//------------------------------------------------------------------//
If you like, you can keep this class in your library.
What all required is :
1) Add the clause "CLASS TXBrWin7()" while creating XBrowse
and
2) set oBrw:nMarqueeStyle := 7
Nothing more is to be done in the application program.