I'm quite new to VC++ and I'm having a problem this morning that is driving me nuts. I'll try to explain it short and clear:
I have a dialog in my app. with just a CRichEditCtrl to make some testing stuff. The goal here is to get the CHARFORMAT from another rich edit view in the app. and set it to this control. I just need to see this test stuff working to get somewhere else, I'll spare you the details.
So I have a class called CTestRtfDialog with a typical TestRtfDialog.h declaration
class CTestRtfDialog : public CDialog
CTestRtfDialog(CWnd* pParent = NULL); // standard constructor
// ClassWizard generated virtual function overrides
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
Plus some event handlers I don't want to bore you with
Then in my CWinApp class' InitInstance method I have some typical things like DocTemplate, ParseCommandLine and at this point where evrything is supposed to be initialized (I've spent pretty enough time tracing to check it out) I have this lines to get the CHARFORMAT from that rich edit view I mentioned before:
// 2. Give InitDialogEvent a try
m_TestRtf.SetDefaultCharFormat(m_DefaultCharFormat); // (!!!)
Hum... doesn't crash but the format in the edit control and in the view don't match... why?
Some more tracing to check it out and I discover that OnInitDialog is triggered BEFORE the point where I call my SetDafaultFormat method, thus m_DefaultCharFormat has some random content.
To be some specific the event is triggered somewhere inside the
that is in InitInstance method and right before my code!
What doesn't make any sense to me is that inside the event handler the assertion complies but LATER in my SetDefaultFormat method IT DOESN'T!
Could someone explainme what's the problem here?
Thanks in advance
Last edited by fotw; February 2nd, 2009 at 08:47 AM.