抱怨VC6//加了RichEdit,Dialog打不開


想說,來練習一下CString的find()。

從MS VC6,開一個MFC的Dialog Project。
用Static Text似乎不可以多行顯下,所以就新增一個Rich Edit來看看。
結果程式改成把字串輸出到Rich Edit就打不了?!



(心想怎麼會這樣?)

再來一次,在MS VC6,開一個MFC的Dialog Project,什麼程式碼都不要打。
直接執行→OK!
新增一個Rich Edit,再執行→NG!

(囧)

上網看了一下,要修改一下程式碼(如下)
BOOL CTempStrFindApp::InitInstance()
{
    
    CTempStrFindDlg dlg;
    m_pMainWnd = &dlg;

    AfxInitRichEdit();

    dlg.DoModal();  //貼在這一行前面就可以了

    return FALSE;
}


MSDN寫的如下 
NoteImportant
If you are using a rich edit control in a dialog box (regardless of whether your application is SDI, MDI, or dialog-based), you must call AfxInitRichEdit once before the dialog box is displayed. A typical place to call this function is in your program's InitInstance member function. You do not need to call it for each time you display the dialog box, only the first time. You do not have to call AfxInitRichEdit if you are working with CRichEditView.


參考資料:Overview of the Rich Edit Control

沒有留言:

張貼留言

(什麼是留言欄訊息?)