Objective Grid: Persisting custom base styles

Article ID: 186
Last updated: 04 Jun, 2018
Article ID: 186
Last updated: 04 Jun, 2018
Revision: 3
Views: 1899
Posted: 23 Jan, 2001
by Meltreger B.
Updated: 04 Jun, 2018
by Meltreger B.

Problem


I am using custom base styles in my grid view and would like to read these base styles from and write them to the profile or registry.


Cause



Action


Take a look at gridsvw3.cpp in gridapp. This registers some base styles (an error style and a combo style) and gives the user the possibility to change these base styles and write them to the profile (or registry). When the user opens a new view, the styles will be initialized with attributes specified in the profile (or registry).

Please take care that you register the base styles before calling ReadProfile(). ReadProfile() will load the setting from the profile and override the standard settings if it can find an entry for the specific base style.

Example:

void CGridSample3View::SetupBaseStyles()
{
ASSERT(GetParam()->GetStylesMap() == NULL);
// ASSERTION-> a stylesmap is already connected to parameter-object ->END
if (GetParam()->GetStylesMap() != NULL)
return;
// create a stylesmap and connect it with the parameter-object
CGXStylesMap* pStyMap;
GetParam()->SetStylesMap(pStyMap = new CGXStylesMap);

// create standard styles
pStyMap->CreateStandardStyles();

// Add some base styles

// "Combo Style" - A style with a combo box and choice list
pStyMap->RegisterStyle(szComboStyle,

CGXStyle()
.SetControl(GX_IDS_CTRL_CBS_DROPDOWNLIST)
.SetChoiceList(_T("one two three four five six ")),
TRUE // system-style (non removable)
);
// "Error Style" - Yellow text on red backcolor with a bold font
pStyMap->RegisterStyle(szErrorStyle,
CGXStyle()
.SetTextColor(RGB(255,255,0)) // yellow
.SetInterior(RGB(255,0,0)) // red
.SetFont(CGXFont().SetBold(TRUE)),
TRUE // system-style (non removable)
);
// I do also want to adapt the base styles:
// StandardStyle() calls pStyMap->
// LookupStyle(pStyMap->m_wStyleStandard, ...)
// and returns a reference to the Standard-Style.
//
// So, I can simply adapt this style's settings to my needs.
StandardStyle()
.SetFont( CGXFont()
.SetFaceName(_T("Times New Roman"))
.SetSize(9));
RowHeaderStyle()
.SetTextColor(RGB(0,0,255) );
// Now, read the styles from profile.
// Note that reading style from profile
// can override the previous settings.
// The previous settings are standard settings.
pStyMap->SetSection(_T("My Base Styles"));
pStyMap->ReadProfile();
}

void CGridSample3View::OnInitialUpdate()
{

BOOL bNew = ConnectParam();
if (bNew)
SetupBaseStyles();
CMyGridView::OnInitialUpdate();

...

}

This article was:   Helpful | Not helpful
Report an issue
Article ID: 186
Last updated: 04 Jun, 2018
Revision: 3
Views: 1899
Posted: 23 Jan, 2001 by Meltreger B.
Updated: 04 Jun, 2018 by Meltreger B.

Others in this category