Discussion:
Creating a simple doc/view control in a dialog box
(too old to reply)
JackSheep
2007-07-06 22:20:02 UTC
Permalink
Hello everyone and all,

I'm wanna have my own custom control in a dialog box that will be derived
from CView and correlate to an object derived from CDocument.
This dialog box is a part of a regular doc/view MDI app, so I already have a
CView-derived class, and a CDocument-derived one.

1) I'm using the wizard to generate stuff, so what should I do to manually
add another doc/view corelation?



2) How do I add my own custom control (derived from a CView or CScrollView)
to a dialog box??

I've tried adding a custom control to it, specifying the "Class" property as
CView, but that made the prog incapable of showing the dialog box, and the
output pane had some mentioning of the lack of AfxEnableControlContainer() in
the app's InitInstance().

Now, my app isn't ActiveX enabled (didn't specify it in the wizard), and to
the best of my understanding of ActiveX (which frankly is lacking) I do not
need it in my app - because I want to use this control only in this app, and
not export it or register it in the system...
All I want is a custom control - I'll write it's drawing & user input procs.
3) Is that ActiveX?

Anyway, I've tried adding a "custom control" to an ActiveX enabled project,
and it didn't show the dialog box either...
4) Why? what is this "custom control" you can add from VS 2005's dialog
editor toolbox (which offline MSDN tells virtually nothing about) - Is that
the way to go about adding my custom control?


Hope you made it reading this far,
I would appreciate whatever sharing of experience you can offer,
Thanks!
Tom Serface
2007-07-06 23:16:13 UTC
Permalink
Maybe this will help you get started:

http://www.codeproject.com/docview/dfv.asp

Tom
Post by JackSheep
Hello everyone and all,
I'm wanna have my own custom control in a dialog box that will be derived
from CView and correlate to an object derived from CDocument.
This dialog box is a part of a regular doc/view MDI app, so I already have a
CView-derived class, and a CDocument-derived one.
1) I'm using the wizard to generate stuff, so what should I do to manually
add another doc/view corelation?
2) How do I add my own custom control (derived from a CView or
CScrollView)
to a dialog box??
I've tried adding a custom control to it, specifying the "Class" property as
CView, but that made the prog incapable of showing the dialog box, and the
output pane had some mentioning of the lack of AfxEnableControlContainer() in
the app's InitInstance().
Now, my app isn't ActiveX enabled (didn't specify it in the wizard), and to
the best of my understanding of ActiveX (which frankly is lacking) I do not
need it in my app - because I want to use this control only in this app, and
not export it or register it in the system...
All I want is a custom control - I'll write it's drawing & user input procs.
3) Is that ActiveX?
Anyway, I've tried adding a "custom control" to an ActiveX enabled project,
and it didn't show the dialog box either...
4) Why? what is this "custom control" you can add from VS 2005's dialog
editor toolbox (which offline MSDN tells virtually nothing about) - Is that
the way to go about adding my custom control?
Hope you made it reading this far,
I would appreciate whatever sharing of experience you can offer,
Thanks!
Mark Salsbery
2007-07-16 15:08:02 UTC
Permalink
Why do you need to derive from CView? That doesn't fit the doc/view model in
MFC.

A CView is a window, not a control, so you need to create it and add it to
the dialog at runtime like you would add any other child window to an
existing window.

Mark
--
Mark Salsbery
Microsoft MVP - Visual C++
Post by JackSheep
Hello everyone and all,
I'm wanna have my own custom control in a dialog box that will be derived
from CView and correlate to an object derived from CDocument.
This dialog box is a part of a regular doc/view MDI app, so I already have a
CView-derived class, and a CDocument-derived one.
1) I'm using the wizard to generate stuff, so what should I do to manually
add another doc/view corelation?
2) How do I add my own custom control (derived from a CView or CScrollView)
to a dialog box??
I've tried adding a custom control to it, specifying the "Class" property as
CView, but that made the prog incapable of showing the dialog box, and the
output pane had some mentioning of the lack of AfxEnableControlContainer() in
the app's InitInstance().
Now, my app isn't ActiveX enabled (didn't specify it in the wizard), and to
the best of my understanding of ActiveX (which frankly is lacking) I do not
need it in my app - because I want to use this control only in this app, and
not export it or register it in the system...
All I want is a custom control - I'll write it's drawing & user input procs.
3) Is that ActiveX?
Anyway, I've tried adding a "custom control" to an ActiveX enabled project,
and it didn't show the dialog box either...
4) Why? what is this "custom control" you can add from VS 2005's dialog
editor toolbox (which offline MSDN tells virtually nothing about) - Is that
the way to go about adding my custom control?
Hope you made it reading this far,
I would appreciate whatever sharing of experience you can offer,
Thanks!
JackSheep
2007-07-18 20:26:06 UTC
Permalink
right,
Thank you.

Continue reading on narkive:
Loading...