Hello,
I think it should work approximately like this. In my code, there is still an issue with the correct size of the restored font.
But I’m sure you can solve that.
The principle is: remember the font size, row height, and column widths from XBrowse.
When restarting, the saved values are loaded.
Best regards,
Otto
Code: Select all | Expand
// Using Windows 7 row selection colors in xbrowse
#include 'fivewin.ch'
#include 'xbrowse.ch'
STATIC nLastFontSize := 0
STATIC aLastColWidths := {}
STATIC nLastRowHeight := 0
STATIC c_path
function Main()
local oDlg, oBrw, oFont
c_path := cFilePath(GetModuleFileName( GetInstance() ) )
SET DATE ITALIAN
SET CENTURY ON
FwNumFormat( 'E', .t. )
USE CUSTOMER ALIAS CUST
DEFINE FONT oFont NAME 'Tahoma' SIZE 0, -16
DEFINE DIALOG oDlg SIZE 640,440 PIXEL ;
FONT oFont TITLE 'XBrowse Windows 7 Bars' ;
COLOR CLR_BLACK,RGB(250,250,250)
@ 0,20 ;
BUTTON "SaveZoomSetting" ;
ACTION SaveZoomSetting( oBrw ) ;
OF oDlg ;
PIXEL
@ 0,120 ;
BUTTON "LoadZoomSettings" ;
ACTION LoadZoomSettings( oBrw ) ;
OF oDlg ;
PIXEL
@ 20,20 XBROWSE oBrw OF oDlg SIZE -10,-20 PIXEL ;
COLUMNS "First", "State", "Age", "HireDate", "Salary" ;
ALIAS 'CUST' NOBORDER
oBrw:lRecordSelector := .f.
oBrw:nMarqueeStyle := MARQSTYLE_HIGHLWIN7
WITH OBJECT oBrw:InsCol( 1 )
:cHeader := " "
:bEditValue := { || If( AScan( oBrw:aSelected, oBrw:BookMark ) > 0, .t., nil ) }
:SetCheck()
:nHeadBmpNo := { || If( Len( oBrw:aSelected ) == oBrw:nLen, 1, 2 ) }
:bLClickHeader := { |r,c,f,oCol| If( Len( oBrw:aSelected ) == oBrw:nLen, ;
oBrw:SelectNone(), oBrw:SelectAll() ) }
END
oBrw:CreateFromCode()
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
return nil
FUNCTION SaveZoomSetting( oBrw )
LOCAL cIniFile := c_Path + "PROJECT.INI"
LOCAL nZoom, i
local cFontText
FontToText( oBrw:oFont )
MEMOWRIT( 'fontsave.txt', cFontText )
// Schriftgröße speichern
WritePProString( "Settings","FontSize", Str( Abs( oBrw:oFont:nHeight ) ), cIniFile )
// Zeilenhöhe speichern
WritePProString ( "Settings", "RowHeight", Str( oBrw:nRowHeight ) , cIniFile )
// Spaltenbreiten speichern
FOR i := 1 TO Len( oBrw:aCols )
WritePProString( "Columns", "Col" + Str(i), Str( oBrw:aCols[i]:nWidth ) , cIniFile )
NEXT
RETURN NIL
FUNCTION LoadZoomSettings( oBrw )
LOCAL cIniFile := c_Path + "PROJECT.INI"
LOCAL i, nWidth
// Schriftgröße setzen
LOCAL nFontSize := Val( GetPvProfString( "Settings", "FontSize", "12" , cIniFile ) )
oBrw:oFont := FontFromText( MemoRead( 'FONTSAVE.TXT' ) )
// Zeilenhöhe setzen
oBrw:nRowHeight := Val( GetPvProfString( "Settings", "RowHeight", "20" , cIniFile ))
// Spaltenbreiten wiederherstellen
FOR i := 1 TO Len( oBrw:aCols )
nWidth := Val( GetPvProfString( "Columns", "Col" + Str(i), Str(oBrw:aCols[i]:nWidth) , cIniFile ))
oBrw:aCols[i]:nWidth := nWidth
NEXT
oBrw:Refresh()
RETURN NIL
function FontToText( oFont )
return FW_ValToExp( { ;
oFont:cFaceName, 0, oFont:nInpHeight, .f., oFont:lBold, oFont:nEscapement, ;
oFont:nOrientation, nil, oFont:lItalic, oFont:lUnderline, oFont:lStrikeOut, ;
oFont:nCharSet, oFont:nOutPrecision, oFont:nClipPrecision, oFont:nQuality, ;
nil, oFont:nPitchFamily } )
//----------------------------------------------------------------------------//
function FontFromText( cText )
return HB_ExecFromArray( TFont(), "NEW", &cText )
//----------------------------------------------------------------------------//