Convert dialog app to doc view app
I suppose I could start all over, but I'm interested to know how I can convert an existing dialog app to doc view app. I would like it to use CFrameWnd and the whole shootin' match, just as if I used the VS wizard. Tutorial links anyone?
[247 byte] By [
sambo] at [2007-11-19 1:21:03]

# 1 Re: Convert dialog app to doc view app
A formview based app ( SDI ) will be the easiest option. A formview takes a dialog template.
# 2 Re: Convert dialog app to doc view app
What are the steps to add the formview arch to an existing dialog based app?
sambo at 2007-11-11 0:53:04 >

# 3 Re: Convert dialog app to doc view app
I would say, do it the reverse way. Make a SDI app which is formview based. Then , paste your dialog code in.
To move the template, simply open your dialog's rc in text mode and copy the IDD_DIALOG... section to your formview app's RC.
All your dialog's code will move to the formview..
# 4 Re: Convert dialog app to doc view app
I created a formview based app and have ported my dialog app code over. I replaced this code (In my CFormView derived class header file)...
enum{ IDD = IDD_APPWIZARD_FORM};
With my dialog template...
enum{ IDD = IDD_MY_DIALOG};
How do I tell MFC that IDD_MY_DIALOG info can be found in "MyDialog.h"? It appears to be looking for the class info in "MyViewClass.h". Of course, it will not find the info there, as I have ported my dialog class over from an existing app.
I keep getting the message box saying, "Failed to create empty document." This occurs when CFrameWnd::OnCreate(lpCreateStruct) fails. When I switch the original enum line back from above, it works and the default form view is shown. This does me no good.
I would also like to be able to change the dialog displayed by the formview on the fly. Much like could be accomplished with a dialog bar.
sambo at 2007-11-11 0:55:00 >

# 5 Re: Convert dialog app to doc view app
I would say, do it the reverse way. Make a SDI app which is formview based. Then , paste your dialog code in. You should follow kirants advice. He mention moving resource and pasting code from you dialog class into a form view.
JohnCz at 2007-11-11 0:56:04 >

# 6 Re: Convert dialog app to doc view app
You should follow kirants advice. He mention moving resource and pasting code from you dialog class into a form view.
I guess I wasn't understanding the fundamental usage of a formview. So the form view takes on the functionality of my dialog? So if I want to interchange dialogs within my formview, I need to create a new formview for each different dialog?
If my original function was..
CMyDialog:: DoThis
It would now become CFormView:: DoThis
And the CMyDialog class goes away completely?
sambo at 2007-11-11 0:57:03 >

# 7 Re: Convert dialog app to doc view app
I guess I wasn't understanding the fundamental usage of a formview. So the form view takes on the functionality of my dialog? So if I want to interchange dialogs within my formview, I need to create a new formview for each different dialog?
If my original function was..
CMyDialog:: DoThis
It would now become CFormView:: DoThis
And the CMyDialog class goes away completely?You have to move (copy) dialog resources into your resource file and create class derived from CFormView for each dialog template.
Then move a code from dialog class to form view class, changing all instances of dialogs class name to form view name.
To make it easier, give your form view derived class the same name as dialogs from the project you are converting.
JohnCz at 2007-11-11 0:57:59 >
