WriteProfileString()
-
after choosing and closing the Font Dialog in an SDI appliction, the last choosen Fon must be saved via WriteProfileString() and by the next call it should be loaded sot that the Font is automatically selected via GetProfileString(). I have the following code: CString strFaceName; CString strFontSize; CString strFontStyle; CString strFontValue; CFont *m_cfont = (CFont*) new CFont(); LOGFONTA *m_lf = new LOGFONTA(); int m_nFontSize = 0; CWinApp* pApp = AfxGetApp(); m_cfdlg.GetCurrentFont(m_lf); strFaceName = m_cfdlg.GetFaceName(); m_nFontSize = m_cfdlg.GetSize() ; m_cfont->CreateFont(m_nFontSize, m_lf->lfWidth,m_lf->lfEscapement,m_lf->lfOrientation, m_lf->lfWeight,m_lf->lfItalic,false,0,1,OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH | FF_SWISS,strFaceName); itoa(m_nFontSize,(char*)strFontSize.GetString (),10); pApp->WriteProfileString(strFaceName, strFontSize, strFontStyle); strFontValue = pApp->GetProfileString(strFaceName, strFontSize, strFontStyle); as i know WriteProfileString, write in the registry, but this code needs something more to work properly?
-
after choosing and closing the Font Dialog in an SDI appliction, the last choosen Fon must be saved via WriteProfileString() and by the next call it should be loaded sot that the Font is automatically selected via GetProfileString(). I have the following code: CString strFaceName; CString strFontSize; CString strFontStyle; CString strFontValue; CFont *m_cfont = (CFont*) new CFont(); LOGFONTA *m_lf = new LOGFONTA(); int m_nFontSize = 0; CWinApp* pApp = AfxGetApp(); m_cfdlg.GetCurrentFont(m_lf); strFaceName = m_cfdlg.GetFaceName(); m_nFontSize = m_cfdlg.GetSize() ; m_cfont->CreateFont(m_nFontSize, m_lf->lfWidth,m_lf->lfEscapement,m_lf->lfOrientation, m_lf->lfWeight,m_lf->lfItalic,false,0,1,OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH | FF_SWISS,strFaceName); itoa(m_nFontSize,(char*)strFontSize.GetString (),10); pApp->WriteProfileString(strFaceName, strFontSize, strFontStyle); strFontValue = pApp->GetProfileString(strFaceName, strFontSize, strFontStyle); as i know WriteProfileString, write in the registry, but this code needs something more to work properly?
you could look at this - Im sure he has a save method in his CFontHelper class ... CFontHelper[^] 'g'