Solved

pseudo-MDI application

Posted on 1997-07-16
3
204 Views
Last Modified: 2013-11-20
I would like to have an application that consists of several
types of documents and views and the views can be seen
together and arranged with the automatic "cascade" and "tile" features you get with MDI.
The problem is, I do not want it to be MDI, i.e. only
one document of each type may exist.
How can I do that ?
0
Comment
Question by:mco
  • 2
3 Comments
 
LVL 4

Expert Comment

by:mbhakta
ID: 1302603
If you are thinking you cannot achieve blocking more than one instance of a view or a document then you should reconsider. There are ways where you can check if a particular document has already been opened by another view. This can be done on a file basis as well as on a C++ object basis. This can be also implemented for views.

Yes, this can be also done without using MDI and instead using SDI or a group of CWnd's (like VB 4.0 does) but this is not clean and often lands with heaps of extra code which would have already been written by MS for a MDI interface.

It is a decision you should make whether you can live with MDI and get the  problem you have sorted out or re-write some  code to get it working on a SDI or worst a dialog based application.

If u come up with more precise details about your problem I will be here to help you.
0
 
LVL 1

Author Comment

by:mco
ID: 1302604
Your answer was general. I was expecting something more specific.
Let me rephrase: I will start it off as an MDI (in order for
Visual C++ do all the work related to the "tile" and "cascade"
features).
How do I prevent another instance of a document (not a view)
to be created.
If you give specific sample code lines, I'll give you an A.

0
 
LVL 4

Accepted Solution

by:
mbhakta earned 100 total points
ID: 1302605
Here is an algorithm : - Start from the active view- Iterate through all the visible (opened) views in the MDI application. Use GetNextView().- Get the document pointer for the view pointer returned from the previous call. - Use IsKindOf() call to check whether the document belongs to a particular class. Keep the count in memory. - Go to the next view. Repeat the previous step. If the counter for that view is more than 1 , that's it you have found another instance of the same doc. Kill that view.Apply this procedure even when a new view is opened. This can go in the OnInitialUpdate() where the view checks for the counter (can be located in theApp). Perform the step 3 and 4 if found.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video discusses moving either the default database or any database to a new volume.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now