OnDraw never gets hit in CRichEditView.

I have a MultiDocumentTemplate with a CRichEditDoc and a CRichEditView.  The OnDraw of the view never gets hit, thus my text never gets drawn.  What could make this happen?  

Everything I find keeps indicating to me that it should all be automatic, what is the general way to display a file with a richeditdoc?  I have looked at WordPad but there is so much going on it is hard to pick out what I do and don't need.
applebyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mikeblasCommented:
The behaviour you're observing is by design.

A CRichEditView actually is a rich edit control. MFC doesn't process the WM_PAINT message because the rich edit control, which is implemented by Windows, does all the painting.

..B ekiM
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
applebyAuthor Commented:
So if I want the file that the document has opened to actually show up in the control, what is the appropriate way to do that?  Right now I have moved the code that I had sitting in OnDraw() to the end of the OnInit method of the view.  Is this a reasonable place for it?  It works but somehow feels like a hack.

(The code I mention basically consists of a SetWindowText() operation on the RichEditCtrl.  The CString I use to set the text comes from a GetData() call on the document that is defined to read all the file text into a CString and return that.)
0
mikeblasCommented:
> So if I want the file that the document has opened to
 > actually show up in the control, what is the appropriate
 > way to do that?  

Any text set to the rich edit control will be drawn by the rich edit control. You don't need to do any extra work.

If you've left the code the way the AppWizard emits it, you'll find that the serialization of the document simply turns around and has the rich edit control suck the rest of the data out of the file you specify.  The CYourDocument::Serialize() implementation calls CRichEditDoc::Serialize() to get that done.

If you've removed that call, the rich edit control won't be loading any data from the file unless you've written some code to do it yourself.

What are you trying to do in OnDraw()? It's very rare to need to draw over what the a control is painting for you.

..B ekiM
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

applebyAuthor Commented:
Nothing draws to the control when I leave the code exactly the way it is generated by the wizard.  To check myself, I generated a brand new project, based it off the CRichEditView, and didn't modify a thing.  I ran it, selected File->Open from the main menu, and chose a file I knew to have text in it that I checked by viewing it in wordpad.  I got exactly the same thing that my real app was giving me - a blank document, with the right title but no visible text, and the cursor blinking at the beginning of the page.  

That said, I am bypassing serialize in my app, because I am dealing with a special case where some of the files will be local and some will be remote, and the remote files are being opened through socket communications, not through a mapped drive.  In place of serialize I have methods in the doc to open, close, and save local or remote files.  The calling code constructs the document itself, it is not opened through OnFileOpen, so I can simply pass in the path and a "remote?" bool to the doc constructor and the rest is handled within.

So I guess that makes two separate questions.  For the sake of me understanding how things are supposed to work, what is up with the autogenerated project that doesn't read in the doc automatically?  And second, given the special circumstances that I'm handling, does it make sense to be forcing the setText in the view's init?
0
applebyAuthor Commented:
I'm starting to wonder if this is an environment-specific problem.  I recall that on another RichEdit-based document template, we were trying to implement the search capabilites that I thought were supposed to be automatic, but when we added the ID to the menu, nothing happened when we selected it.  Are there any known issues that could cause some of the default capability to just not work?  I'm running MSVCPP6.0 with Service Pack 2 on NT4.0 with Service Pack 4.
0
mikeblasCommented:

 > a blank document, with the right title but no visible
 > text, and the cursor blinking at the beginning of the page.  

Does the file you're opening contain RTF formatted text?  If it doesn't, the control won't display it. You need to tell the control you want it to parse plain text.

To do that, you can set m_bRTF to FALSE in your document.

 > And second, given the special circumstances that
 > I'm handling, does it make sense to be forcing the setText
 > in the view's init?

That seems reasonalbe, though you'd probably be better off with streaming than setting.  See the EDSTREAM.ZIP sample on my webpage at http://www.nwlink.com/~mikeblas/samples/ .  (Note that my webpage will someday move to http://www.mooseboy.com/ )

..B ekiM
0
applebyAuthor Commented:
Ok, makes sense.  I'll check out the sample, thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.