Having built a 'std' SDI program, I was wanting to control the font & cursor for the dialog. S ofar, the only help /code I can find always relates to the primary apps "ondraw" function. Is there an alternative to use SelectObject or get the device context?
I have snipped a piece of code I've been working with ....
Code:
// CDCTestFont3App commands
BOOL CAboutDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// In this situation - what would be the code to handle resources correctly using
// SelectObject() - I'm presuming it is neccesary and that a CFont *oldfont would
// also be required. (The book i'm reading warns about resource leaks in this situation.
// The problem is determining what device context would be used to handle
// SelectObject for the dialog box. - is it: this.SelectObject, or is some form
// of assignment of a type via a pointer required?
LOGFONT fontdata; // Create the LOGFONT structure...
ZeroMemory( &fontdata, sizeof(LOGFONT) );
GetDlgItem(IDOK)->GetFont()->GetLogFont(&fontdata); // Copies font info into fontdata
fontdata.lfWeight = FW_SEMIBOLD; // Set the weight of the font
lstrcpy(fontdata.lfFaceName, "Arial Narrow"); // Change the name of the font
new_font.CreateFontIndirect(&fontdata); // Create a new font with the specified LOGFONT parameters
GetDlgItem(IDOK)->SetFont(&new_font); // Assign the font to the widget
// If attempt to use same font again it would fail as font create already
// need to have individual font for each style to be used.
ZeroMemory( &fontdata, sizeof(LOGFONT) );
GetDlgItem(IDC_AboutTitle)->GetFont()->GetLogFont(&fontdata);
fontdata.lfWeight = FW_THIN; // THIN TEXT
fontdata.lfItalic = TRUE;
lstrcpy(fontdata.lfFaceName, "Comic Sans MS");
title_font.CreateFontIndirect(&fontdata);
GetDlgItem(IDC_AboutTitle)->SetFont(&title_font);
GetDlgItem(IDC_AboutCopyright)->SetFont(&title_font);
CWinApp* pApp = AfxGetApp();
if( pApp != 0 )
{
m_hIconOkay = pApp->LoadIcon( IDI_GreenIcon );
m_hIconCancel = pApp->LoadIcon( IDI_RedIcon );
ASSERT(m_hIconOkay);
ASSERT(m_hIconCancel);
m_AboutOK.SetIcon( m_hIconOkay );
m_AboutCancel.SetIcon( m_hIconCancel );
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
Code tags added by Kermi3