15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


CRichEditCtrl problem

Terry Wellmann -- wellmatl@cs.purdue.edu
Tuesday, February 13, 1996

I need to display text in a monospaced font in a dialog box.  I need to be
able to scroll the text.

I tried to use CEdit but I couldn't display the text in a monospaced font.
I then tried to implement a CRichEditCtrl but I had troubles getting it to
show up in my dialog box.  I don't have a button for it in my Control Bar,
am I missing anything?

I then set up a frame and manually created a CRichEditCtrl object but it
didn't work.  In my OnInitDialog() I've done the following:

WINDOWPLACEMENT wp;
wp.length = sizeof(wp);
m_RTFFrame.GetWindowPlacement(&wp);  // m_RTFFrame is the id of the frame

m_RTFEdit.Create(WS_CHILD | WS_VISIBLE | ES_MULTILINE, wp.rcNormalPosition,
this, IDC_RTFEDIT); // m_RTFEdit is my CRichEditCtrl object



What am I doing wrong?

Thanks,

Terry


-----------------------------------------------------------------------
|                          Terry Wellmann                             |
|                  CS Major - Purdue University                       |
|             Programmer/Systems Analyst - M.A.I.L.code Inc.          |
|                   E-Mail: wellmatl@cs.purdue.edu                    |
|              http://www.cs.purdue.edu/people/wellmatl               |
|=====================================================================|
|                                                                     |
| " ..655,360 bytes is more than enough for any application we could  |
|     ever develop."         - Bill Gates in PC Monthly, Aug. 1983    |
|                                                                     |
-----------------------------------------------------------------------






Brad Wilson -- bradw@netnet.net
Friday, February 16, 1996

> I need to display text in a monospaced font in a dialog box.  I need to be
> able to scroll the text.
>
> I tried to use CEdit but I couldn't display the text in a monospaced font.

1. Add a CFont member to the dialog box
2. In OnInitDialog(), call CFont::CreateFont() (or CreateFontIndirect())
3. In OnInitDialog(), call CMyEdit::SetFont() with the newly created font

While CRichEditCtrl is a nice thing for multiple-fonts in a single edit
control, it's overkill for you.  :-)

Brad

--
class CBradWilson : public CWorldWatchProgrammingTeam {
  public:
    void GetInetAddr  ( CString& s ) { s = "bradw@exptech.com";      }
    void GetE164Addr  ( CString& s ) { s = "+1 (810) 620-9803";      }
    void GetURL       ( CString& s ) { s = "http://www.exptech.com"; }
    void GetDisclaimer( CString& s ) { s = "All I say is fact :-p";  }
};

//  QOTW:  "Music nowadays is merely the art of executing difficulties and in
//          the end that which is only difficult ceases to please."




DORIE@ris.risinc.com
Friday, February 16, 1996

I have a CRichEditCtrl in a dialog.  This is what I did to make it 
work.  I created my dialog with an edit control.  I then added a 
member variable for this edit control.  I went into the Code and 
changed the reference to CEdit to be CRichEditCtrl.  I then proceeded 
to place the following lines of code in the InitInstance() section of 
my App.  

	InitCommonControls ();
#ifdef _MAC
	hinstRE = RELoadLibrary();
#else
	// Initialize RichEdit control
	if ((hinstRE = LoadLibrary(_T("RICHED32.DLL"))) == NULL)
	{
		AfxMessageBox(IDS_RICHED_LOAD_FAIL, MB_OK|MB_ICONEXCLAMATION);
		return FALSE;
	} 
#endif

Note that the #ifdef _MAC is there because I am cross- 
compiling.  Then I included RichEdit.h in my main app header file.  
You may be able to include these things in different places but you 
definitely need to include the RichEdit.h, load the library and call 
InitCommonControls() to get the control to work.  Hope this helps.
Dorie Hannan.




| Вернуться в корень Архива |