Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Font modification is not proper in ListCtrl !!

vasanthgvvasanthgv Member Posts: 1
Hi,

I am facing a problem related to Font support on SDI application.
Control used is List Control.
Class 'CSamp' mentioned below in the sample Source code is derived from CListView.

PROBLEM :

Source Code :

void CMainFrame::OnSelectFontStyle()
{
// Font Structure
LOGFONT lfwork;
// Application Object
CPSMApp* pApp = (CPSMApp*)AfxGetApp();

lfwork = pApp->m_LogFont;
// Create a Font Dialog
CFontDialog w_dlg( &lfwork );

// Flags used to indicate the User's input
w_dlg.m_cf.Flags ^= CF_EFFECTS | CF_FORCEFONTEXIST;

// Opens the Font dialog
if (w_dlg.DoModal() == IDOK)
{
// Load wait cursor
CWaitCursor obWaitCursor;

// Gets the Font selected in the Dialog
w_dlg.GetCurrentFont(&(pApp->m_LogFont));

// If current view is Installed Software screen
CSamp *pobInsSoftView = m_pobDoc->GetSoftwareView();

// Apply font on Software View
pobInsSoftView->FontChange( &pApp->m_LogFont);
pobInsSoftView->LoadImageList();
pobInsSoftView->Invalidate();

}
}

void CSamp:FontChange( LOGFONT* rlogfont )
{
if( m_FontFlg == TRUE )
{

CFont* pOldFont = NULL;
CDC* pDC = GetDC();
TEXTMETRIC tm;

memset( &tm, 0x00, sizeof(tm) );

// Delete if CFont object already exists
if( m_LBfont != NULL )
{
m_LBfont->DeleteObject();
delete m_LBfont;
}

// Create new CFont object
m_LBfont = new CFont;
if( m_LBfont == NULL )
{
return;
}

// Initializes a CFont object m_LBfont
m_LBfont->CreateFontIndirect( rlogfont );

pOldFont = pDC->SelectObject( m_LBfont );

if( pDC->GetTextMetrics(&tm) )
{
// Set List Item height
m_nItemHeight = tm.tmHeight + 1;
}

ReleaseDC( pDC );

// Changes the current font of the window
SetFont( m_LBfont, TRUE );

// Reset the charset to the original value.
rlogfont->lfCharSet = lCharSet;
}
return;
}

Behaviour :
While switching between Non-Japanese Support Font to Japanese Support Font and vice versa., Font application is not taking place properly.
Only when we refresh the screen, actual font application is taking place.

Scenario :
When i select Non-Japanese Support font (Ex. 'Times New Roman' , it displays Junk characters which is a normal behaviour.
Now when i switch from existing Non-Japanese support font to Japanese support font, even now it displays Junk characters and
only when i refresh, actual Japanese characters are displayed.


REQUIRED BEHAVIOUR :

When I set Japanese Support font, the Japanese characters should be displayed without refreshing in all possible combination
disregarding whether previously selected font is Non-Japanese support font or not.

In the above mentioned Method, actual font change takes place only when the screen is refreshed.

I need the font change to happen without refreshing or using UpdateAllViews().


OS : Windows NT 4.0 SP6a Japanese
Control used : ListCtrl
Application Type : SDI


Thanks & Regards,
Vasanth Kumar G
Sign In or Register to comment.