Link to home
Start Free TrialLog in
Avatar of sweetgirl
sweetgirl

asked on

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

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?
-sweetgirl-
Avatar of AlexNek
AlexNek

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?
Avatar of sweetgirl

ASKER

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?
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?
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.
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.
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).
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?
ASKER CERTIFIED SOLUTION
Avatar of AlexNek
AlexNek

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial