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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple (Different Views) in a MDI 1

Status
Not open for further replies.

JonCage

Programmer
Jul 22, 2003
5
GB
Hi, I've got a problem trying to use multiple views in an MDI application I'm developing. Basically, I want to store all the data in the document and then have a number of different views into that data. Now the difficulty is that i want to write a seperate class for each view (all of which will be derived from a simle class with lots of standard OpenGL drawing stuff in).

Now I've found a lot of stuff on the web but it's all either out of date, un-compilable or not quite what I'm after.

Any comments / suggestions would be very much appreciated!
 
For an intro to it, use the AppWizard. Create an MFC MDI application, "Windows explorer" style. It contains two views one tree ctrl view and ont list ctlr view (ie 2 different views).

The key is to use a CSplitterWnd, which holds the various views.



/Per
Nerdy signatures are as lame as the inconsistent stardates of STTNG.
 
I'm not after a split view though - I wanted individual windows that can be shifted around. I read the stuff in another thread (thread116-579560 which seems sort of along the lines of what I'm after, but I couldn't seem to use more than one type of view at any one time.

As far as I can see you can only use one type of view with a particular document? Maybe I've over-looked something obvious?

I've tried what most of the articles, guides and threads have hinted about using everal document templates e.g.

m_pBookViewTemplate = new CMultiDocTemplate(IDR_BOOKFRAME,
RUNTIME_CLASS(CChkBookDoc),
RUNTIME_CLASS(CCheckBookFrame),
RUNTIME_CLASS(CBookView));
AddDocTemplate(m_pBookViewTemplate);

m_pCheckViewTemplate = new CMultiDocTemplate(IDR_CHECKFRAME,
RUNTIME_CLASS(CChkBookDoc),
RUNTIME_CLASS(CCheckBookFrame),
RUNTIME_CLASS(CCheckView));
AddDocTemplate(m_pCheckViewTemplate);

But when I have more than one template, compile and run the program, I no-longer get any views appearing at all!

What am I doing wrong? How should I be going about this? Thanks in advance for any suggestions...
 
Jon, what are you trying to do, you can use multiple views of the same document, thats what the MDI framework is for.

But if you are using OGL, is what you are trying to do going to be easier using a common OpenGL View Class, and setting each view that you create to a different viewport ?

Without knowing what you are trying to do, I can't say too much more as all my books are at work.

K


 
>thats what the MDI framework is for.

Not really. Its for managing multiple documents in the same application.

With MDI (and SDI) is it quite easy to have multiple views of a certain document, provided that they are all of the same class. If you're into using different view classes for the same document it gets a bit trickier.


/Per
Nerdy signatures are as lame as the inconsistent stardates of STTNG.
 
PerFnurt has really hit the nail on the head. I want to make a model viewer (mostly for terrain generation) and have multiple camera views at once - each showing the user different views. As well as that, it would be nice to have some other views into the data, listing what cameras I've got as well as information about the terrain etc.

I thought about using multiple OGL viewports, but having seperate windows (views) has advantages in that I can use non-OGL windows as well. I'd like to end up with something along the lines of Lightwave, Maya etc. with several different views looking at the same scene. I don't, however, want the views all glued together though - seperate windows are what I'd like.

From what I read, MDI was the way to go, but as per usual, I seem to be doing something that microsoft hadn't _quite_ intended! I'm not bothered about having more than one document open at once, but with SDI, it didn't seem possible to have more than one view visible at once?

You say it's a little more tricky PerFnut, how about some hints? :)
 
>I seem to be doing something that microsoft hadn't _quite_ intended

I know the feeling. The "MFC" way of having multiple view classes is to use splitters. If you insist that you want you views in separate windows it is hard work.

A link on the subject:





/Per
Nerdy signatures are as lame as the inconsistent stardates of STTNG.
 
Yeah, I'd already found that link - there's another couple on the code project site which repeatedly popped up in my googling.

I had a fiddle with it, but couldn't see how to create a new window with a specific view class. I wanted to be able to click a button or select a menu item which would open a new window based on a specific view class.

Thanks for the suggestions guys - keep it coming! :)
 
>I wanted to be able to click a button or select a menu item which would open a new window based on a specific view class.

But the example I linked to does that very thing.



/Per
Nerdy signatures are as lame as the inconsistent stardates of STTNG.
 
Just a note:
I was once into a similar problem. Reluctantly I went "oh, what the heck I'll use the darn CSplitterWnd then".

Afterwards I actually found the splittier thingie to be a better solution:

Consider you manage to have all your views in separate windows. Wouldn't it be quite messy if you have, say, 3 documents open in your MDI? There'd be a lot of windows and I bet the user (you?) sooner or later would get confused about which view is for which doc etc.

I say, go for splitters. After a while you might pout (just like me): "bah, I didn't want the separate view windows anyway". :)

/Per
Nerdy signatures are as lame as the inconsistent stardates of STTNG.
 
Thanks again for the speedy response. My only reservation about using a splitter window is what I do when I have my main view and (say) 5 smaller views. I've done other (similar) applications and regretted having the smaller windows when I had a few going. Perhaps that would still be a problem if I had the extra windows within an MDI app. Maybe I should go for the splitter window + a few modeless dialogs for the extra views? How difficult d'you think it would be to tie the dialogs in with the document/view arcitecture?

Incidentally, I will only ever have one document open at a time - I only used an MDI as that seemed the only way to get more than one view on the screen at a time.

I'll have another look at the example and maybe dabble in some splitters. Thanks for all the help - have a star :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top