C++ MFC

Moderators: Lundin
Number of threads: 3337
Number of posts: 9005

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Font modification is not proper in ListCtrl !! Posted by vasanthgv on 18 Mar 2003 at 9:47 PM
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



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.