How to load an existing document template during run-time?

Posted on 2002-04-13
Last Modified: 2013-11-20
I have many document templates in a SDI application and I would load different document templates when user click on a particular menu item. For eg., when user click on 'Login' on the menu, how do I enable the program to load a particular document template to replace the recent one? Is this done by using the Runtime_Class? but how?
Question by:sweetgirl
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
LVL 16

Expert Comment

ID: 6942291
2 sweetgirl
I don't think that you found a good solution for SDI because CSingleDocTemplate set CWinThread::m_pMainWnd for current opened frame. So you will be need to replace m_pMainWnd with a new one - and this is very bad idea IMHO.

Why you not try an other design? And why you need for Login dialog a Template is it not easy to make with the Dialog?

Author Comment

ID: 6946848
The reason I chose SDI is because I only want one(single) document to be loaded at a time. Perhaps, I might not need it for 'Login' purpose, but I have document templates for other purposes. My idea is to have different forms (can this be considered as document template?) for different purposes...something like forms in Visual Basic. So, when user click on a menu item, the specific form for that would be loaded, and the existing form would be unloaded, and only a single form would be displayed at a time. How can I do that?
LVL 16

Expert Comment

ID: 6948877
I think, that easy solution (as SDI+reloading) is to use MDI application with single opened form limited. But I try to find a better solution for you.
What do you mean under the "Form". Which kind of information do you need on? Is there input fields?
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 6950053
The "Form" I meant is s/thing like having multiple document templates that have controls such as edit box and buttons. I have learnt how to load the specific template during run-time. For a MDI app, it would be OK, but if the same technique is used in a SDI app, it would load a different window that holds that template, which acts as a child of the main window. So, when the parent window closes, the child window closes as well. All I want is a SDI app that could dynamically load 1 document template at a time, in the same window, during run-time. Logically, the current template would need to be unloaded so that the other document template could replace it in a SDI app.
LVL 16

Expert Comment

ID: 6951904
It seems that you need different selectable groups of user input. It look like Property Pages in dialog. Why you don't want to use this way?
Or probably it is possibly (I must check it) that you reload only View but not the whole Doc-View-Frame.
LVL 16

Expert Comment

ID: 6951956
Easy view reloading seems not be possible. You can try to create series of Modeless dialog boxes like in CFormView and manage it yourself (Hide/Show).

Author Comment

ID: 6952930
What do u mean by creating series of Modeless dialog boxes like in CFormView? I thought dialog boxes belongs to CDialog class, which is different from CFormView class! If I have not mistaken, a menu bar can be attached to a dialog box. So, perhaps creating a dialog box application with the menu bar would be essential for my purpose, since dialog boxes can be managed through Hide/Show. In a SDI/MDI application, during runtime, how do I close that view? What method would perform this function?
LVL 16

Accepted Solution

AlexNek earned 50 total points
ID: 6953295
>What do u mean by creating series of Modeless dialog boxes like in CFormView.

If you look in source code, CFormView create a modeless dialog. My trick-idea was that you can load over old View your new form from resource as modeless dialog. Then hide old.

If you can accept dialog with menu bar it will be better idea. Note: CDialog and Dialog template in resource it is not the same. Dialog template you can use in other classes.

For dialog mode:
You can use Property pages (sub dialogs in dialog), you can use Left-Right Panels (Left panel contain list of all dialogs, right - current dialog) or Wizard mode (one dialog after other).

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Strange date stored 22 172
Expand to include initial dialog with two choices. 9 86
Detect file exist or not 3 199
Problem to event 3 112
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

756 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