locked
CRichEditView::OnCreate RRS feed

  • Question

  •  I am using MFC single document with base class CRichEditView.

     I want to display some text on my editor when the editor first opened.

     I tried this way

     but the folowing fragment does not set the editor text on start up

     int CMyView::OnCreate(LPCREATESTRUCT lpCreateStruct)


     {


       if (CRichEditView::OnCreate(lpCreateStruct) == -1)  
       return -1;

    // TODO: Add your specialized creation code here


        GetRichEditCtrl().SetWindowText("Hello World");


        return 0;
     }


    what do u think is the problem.

    is there any function call that will reset windows text after call of OnCreate.

    Sunday, August 6, 2006 9:46 PM

Answers

  • Because you are using the doc view architecture the function OnNewDocument or DeleteCOntents might do this.

    OnCreate might be the wrong place to load the views contents when you want to use the Doc/View architecture.

    Monday, August 7, 2006 6:28 AM
  • Maybe you should set the text in OnInitialUpdate handler?

          

    void CMyView::OnInitialUpdate()

    {

        CRichEditView::OnInitialUpdate();

     

        GetRichEditCtrl().SetWindowText(_T("Hello World"));

    }

     

    I hope it helps.

    Monday, August 7, 2006 7:38 AM

All replies

  • Because you are using the doc view architecture the function OnNewDocument or DeleteCOntents might do this.

    OnCreate might be the wrong place to load the views contents when you want to use the Doc/View architecture.

    Monday, August 7, 2006 6:28 AM
  • Maybe you should set the text in OnInitialUpdate handler?

          

    void CMyView::OnInitialUpdate()

    {

        CRichEditView::OnInitialUpdate();

     

        GetRichEditCtrl().SetWindowText(_T("Hello World"));

    }

     

    I hope it helps.

    Monday, August 7, 2006 7:38 AM