Serializing and font problems...

Problem number 1:
------
I've created simple text editor SDI Application, base View class is: CRichEditView.
I want to serialize it as simple text, without RTF stuff, and save it with ASM file

extension, so i changed m_bRTF to FALSE, everything works....but:

when i create document, type something there, save it, and try to open with MS Notepad

Application, i see one space before my text!!! why is it so?

for example, in my application i type word:test, and save it to asm2.asm
everything ok...but when i open this file with Notepad, i see: test,
there is one space before the "test" word! why? how to fix it??

Problem number 2:
------
In the same Application i want to use font "Courier New" with yHeight parameter = 200,

ONLY! Not any other font and size! So...i made the following:

CRich5View.cpp

void CRich5View::OnInitialUpdate()
{
CRichEditView::OnInitialUpdate();

// Set the printing margins (720 twips = 1/2 inch)
SetMargins(CRect(720, 720, 720, 720));

// I WANT TO USE ONLY THIS FONT
CHARFORMAT2 cf;
cf.dwMask = CFM_COLOR | CFM_FACE | CFM_BOLD | CFM_SIZE;
cf.dwEffects = CFM_FACE;
cf.yHeight = 200;
cf.crTextColor = RGB(0,0,0);
strcpy(cf.szFaceName,"Courier New");
SetCharFormat (cf);

CRich5Doc* pDoc = GetDocument(); // getting document.
CRichEditView::GetWindowText(pDoc->m_strText); // Storing text to m_strText
}

When i save/open/edit *.ASM files, font is this one... But when i try to open

another...for example *.TXT file, font changes!!! How to make it not to change? and always

be like this one??

Here are some parts of another main code:

CRich5Doc.cpp

CRich5Doc::CRich5Doc()
{
m_bRTF = FALSE; // This is done for standard text formatting.
}

CRich5Doc.cpp

void CRich5Doc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
ar << m_strText;
}
else
{
// TODO: add loading code here
ar >> m_strText;
}

// Calling the base class CRichEditDoc enables serialization
// of the container document's COleClientItem objects.
// TODO: set CRichEditDoc::m_bRTF = FALSE if you are serializing as text
CRichEditDoc::Serialize(ar);
}

thanks very much.
[2495 byte] By [EliteT] at [2007-11-18 1:40:09]
# 1 Re: Serializing and font problems...
anyone help
EliteT at 2007-11-10 8:55:14 >
# 2 Re: Serializing and font problems...
problem 1:

Perhaps the problem is cause by serializing mechanism.Or your data have one space or other character which can not be saw.

problem 2:

Perhaps you should try to set the font after you have open it and read the text.
sm_ch at 2007-11-10 8:56:14 >
# 3 Re: Serializing and font problems...
I stil cannot do anything with problem 1! :( I didnt touch any other code, only that which i showed you, but dont know how to remove that ##*%@$& space before my text in files!!
--

Problem 2, is halfly solved... i've created event handler for Save menu, and set up my font there, and then wrote: CRichEditDoc::OnFileSave();

But What to do with file Open?? Look at my code:

void CRich5App::OnFileOpen()
{
// Font and Style
CHARFORMAT2 cf;
cf.dwMask = CFM_COLOR | CFM_FACE | CFM_BOLD | CFM_SIZE;
cf.dwEffects = CFM_FACE;
cf.yHeight = 200;
cf.crTextColor = RGB(0,0,0);
strcpy(cf.szFaceName,"Courier New");
SetCharFormat (cf);

CWinApp::OnFileOpen();
}

here is an error:
error C2352: 'CRichEditView::SetCharFormat' : illegal call of non-static member function

that is because i called SetCharFormat in CWinApp class...but when i create event handler for Open in my View or Doc class... it doesnt knoe OnFileOpen Function!!!!!
what to do? please help... i hope u understood my problem.
thanks
EliteT at 2007-11-10 8:57:13 >