Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CRichEditView with Dialog MFC app in VS 6.0 1

Status
Not open for further replies.

sedj

Programmer
Aug 6, 2002
5,610
Hello,

I'm confused.
When creating the simplest of dialog-based MFC exe app (using the Wizard), if I add a CEditView, all is well. If I use a CRichEditView though, then the app will not run (but compile & links OK).

Creating a simple SDI doc with CRichEditView as the base class is not a problem.

Any ideas why ?

Cheers
 
>Any ideas why ?

You're mixing the two styles of MFC applications.

Either your App is
1) A dialog app
or
2) A document-view app.

You try to do both in one...


/Per

"It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure."
 
Madness, I added AfxInitRichEdit() at the end of the InitInstance() method, and it does not work. But if you add it at the beginning of that method it does !

Thanks for the help.


--------------------------------------------------
Free Database Connection Pooling Software
 
I suggest you start over and create an doc-view application, rather than a dialog based one.

Then getting a rech edit control/view to work is trivial.

/Per

"It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure."
 
PerFnurt :
Well after much pain with the dialog app, I took your advice, and created an MDI app.

So now I have two child frames, one that is based on CFormView, and one based on CRichEditView (interstingly, still needed to call AfxInitRichEdit() to get the edit view to initialize).

But I am completely stumped as of how to retrieve the data from the edit view (such as some text) on an event such as a button click from the form.

Basically, how can you get a handle from one doc to another doc ?
I've been playing with using the main app handle from AfxGetApp() call, but to no avail.

Anybody any ideas ? I'm about to lose the will to live I think !

 
>Basically, how can you get a handle from one doc to another doc ?

I'd suggest you have 1 doc and 2 views. The 2 views (one based on CFormView the other based on CRichEditView). Easiest way is to glue 'em together using a CSplitterWnd (let the appwiz create an explorer style MDI or SDI and see how it handles the tree/list views).
-----
You're not supposed to share data between docs (that's not the intent of the doc-view style anyway).

In the doc-view concept the document is the "center" holding the data and owning a bunch of (well, at least one anyway) views knowing how to present/edit the data. The doc tells its views to "update yourself!" and the views asks the doc "sure, what ya' got?".

To confuse this fairly common concept (called the observer pattern) M$ decided to make an exception when it comes to the edit views, and decided to let edit views hold the data themselves (and not only presentation logic).

So, how do you talk "between views"? Well, since the doc owns all views you can ask it for the "views!=this view" (traverse using the CDocument's GetFirstViewPosition/GetNextView methods).
-----
The difference between MDI and SDI is just that an MDI can handle more that one doc at the same time - each doc is still the "center" of its own little world.




/Per

"It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure."
 
Hi,

Thanks for that, it pointed me in the correct direction. In the end I used :

Code:
	for(POSITION tPos = AfxGetApp()->GetFirstDocTemplatePosition();tPos!=NULL;) {
		CDocTemplate * ptempDocTemplate = AfxGetApp()->GetNextDocTemplate (tPos);
		for(POSITION vPos = ptempDocTemplate->GetFirstDocPosition();vPos!=NULL;) {
			CDocument* cd = ptempDocTemplate->GetNextDoc(vPos);
			AfxMessageBox(cd->GetTitle());
		}

	}

--------------------------------------------------
Free Database Connection Pooling Software
 
Heh, what you're doing is actually a contradiction my my doc-centric suggestion, but I'm happy to help anyway :)

/Per

"It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top