mfc >> faq add view to dialog

by Ajay Kalra » Thu, 23 Mar 2006 10:44:21 GMT

It can be done but you have to do some work. By default a view expects a
CFrameWnd derivative as a parent. Search MSDN for CHTMLCtrl which shows how
to take a view (in this case CHTMLView) and put it in a dialog. Keep in mind
though this is not a normal scenario and you should not use a view in a
dialog. Its better to have a CFormView based SDI/MDI application instead.


"fcvcnet" < XXXX@XXXXX.COM > wrote in message
news: XXXX@XXXXX.COM ...
> Hi,
> We can add view to SDI or MDI project, is it possible to add view in a
> rectangle region within dialog box?
> Thanks.
>
>




mfc >> faq add view to dialog

by fcvcnet » Thu, 23 Mar 2006 11:13:17 GMT


Thanks. My project is based on dialog and there is a graph shows real time
data I take from www.codeproject.com , but it is based on CView , so I want
to add view to my dialog.
Now I put a static to hold the graph and display the data well , but I am
afraid something will happen future. Wanna help so much, I love newsgroup.





mfc >> faq add view to dialog

by Tom Serface » Thu, 23 Mar 2006 11:45:25 GMT


faq add view to dialog

by Ajay Kalra » Thu, 23 Mar 2006 12:50:50 GMT




want

You should be able to extract the logic of drawing the graph from view
rather easily. I would go that way or simply use a CFormView in SDI/MDI.






faq add view to dialog

by fcvcnet » Thu, 23 Mar 2006 14:32:54 GMT

Thanks, I have thought to extract the logic of drawing the graph from view ,
but I am afraid to make mistake. Still I will try.
Thanks you again.




faq add view to dialog

by fcvcnet » Thu, 23 Mar 2006 14:40:21 GMT

Cool, this is what I want I think.
the code I wanna use is also in codeprject
http://www.codeproject.com/miscctrl/xgraph.asp?df=100&forumid=3502&select=14
18310&msg=1418310
but some bugs in it.
The demo and src code the authorer upload does not compile correctly, when
you finishe correct, you will find that the dll you create can not be used
by the demo/bin *.exe which the authorer created, such as double click the
XGRAPH. It seem like something whih do by "you" is wrong. Headache!

"Tom Serface" < XXXX@XXXXX.COM >
:# XXXX@XXXXX.COM ...






faq add view to dialog

by David Webber » Thu, 23 Mar 2006 21:11:03 GMT






The secret is to do it a little bit at a time.

For example if you have

class CMyView : CView
{
};

Introduce a drawing object:

class CMyView : CView
{
CMyPainter m_paint;
};

Start with the lowest level drawing functions and make them public members
of m_paint.
Check that the code still works.
Move more to m_paint.
Check that the code still works.

As methods in m_paint become called only by other methods in m_paint, make
them private.
Check that the code still works.

Ultimately you should end up with something like

class CMyPainter
{
public:

TopLevelDraw( CDC *pDC, ....);

private:

// Lots of other stuff.

};


At this stage you can create a button for a dialogue box:

class CMyButton : public CButton
{
CMyPainter m_paint;
};

make it owner draw and call

m_paint.TopLevelDraw(...)

from your OnDraw()

member.

The print is that you can change a little bit at a time, make sure it still
works, and correct any problems as you go along, whereas debugging it all at
once might be an awful pain. A sort of encapsulation by stealth. :-)

Dave
--
David Webber
Author MOZART the music processor for Windows -
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mzusers/mailinglist.htm







faq add view to dialog

by AliR » Fri, 24 Mar 2006 00:34:50 GMT


faq add view to dialog

by fcvcnet » Fri, 24 Mar 2006 08:55:02 GMT

Hi,
We can add view to SDI or MDI project, is it possible to add view in a
rectangle region within dialog box?
Thanks.




faq add view to dialog

by fcvcnet » Fri, 24 Mar 2006 09:40:25 GMT

Thank you very much.
Something I do not understand.
"Start with the lowest level drawing functions and make them public
members of m_paint."
"lowest level drawing functions " I do not understand ,
did you mean function such like "moveto","lineto" etc.? or you mean function
at the end of calling sequence?
For the first , the function should be public members as you say , but
class CMyPainter
{
public:

TopLevelDraw( CDC *pDC, ....); // "Top" puzzled me
For the second , the function should be private members as you say , but
class CMyPainter
{
public: // "public" puzzled me

TopLevelDraw( CDC *pDC, ....);
I am puzzled.
Thank you again.





faq add view to dialog

by Dan Bloomquist » Fri, 24 Mar 2006 11:27:35 GMT





If I were to write a page, I would start like this:

**
What is object oriented programming?

For programmers that are learning this can be mystical. I was there. My
background was procedural starting with machine, (not assembly!)

If you would like to skip this page, the best oldest book on the subject:

An Introduction to Object-Oriented Programming
Timothy Budd
http://www.amazon.com/gp/product/0201824191/002-4975922-3252069?v=glance&n=283155
**

Does the cover look familiar?

If you google: "Object Oriented Programming

The first page from Sun sucks
http://java.sun.com/docs/books/tutorial/java/concepts/
Maybe clicking through would work, but that page would make my eyes
glaze over if I didn't know what the premise was.

The second page may not be so bad (I have not reviewed it):
http://www.zib.de/Visual/people/mueller/Course/Tutorial/tutorial.html

But if you are going to read that much, lay back, use the book. Timothy
won't use concepts before they are defined.

Best, Dan.


--
"We need an energy policy that encourages consumption"
George W. Bush.

"Conservation may be a sign of personal virtue, but it is not a
sufficient basis for a sound, comprehensive energy policy."
Vice President Dick Cheney



Similar Threads

1. faq: customize the file open dialog's view mode

2. faq how to add print to dialog

Hi,
   There is a graph in my dialog based programme. The demo code is based on
CView, so it has
OnPreparePrinting(CPrintInfo* pInfo)
OnPrint(CDC* pDC, CPrintInfo* pInfo)

   How I can add those function to my code? Or to create the device context
of it.
The graph is creat on a static control.
    I realy need the CDC* pDC .
Thank you so much.


3. How to add a Dialog in a View

4. Dialog ontop of Form View View Problem

Hai
  I am calling a Dialog from FormView and when i call that Dialog the Dialog
is always at the top of the view and i want view to be on top of Dialog when
i click  mouse on the view and is there any thing that iam doing wrong
               Thanks and Regards
                suresh


5. faq how to add jpg to static control

6. faq CArray member function Add problem

Hi,
   Headcke!
   I define some classes as fellows:
CMyPoint
{
...
	CMyPoint(const long &xx, const long &yy);
	CMyPoint(const CMyPoint &cmpt);
	CMyPoint(const CPoint &cpt);
	CMyPoint& operator = (const CMyPoint &assmypt);
	CMyPoint& operator = (const CPoint &asspt);
...
};

CSegment
{
...
CList<CMyPoint,CMyPoint> m_PointList;
...
CSegment& operator = (const CSegment& asssignsegmet);
...
};

But when I use them

	CArray<CSegment,CSegment> tmpmyarray;
	CSegment tmpsegment;
	tmpsegment.m_PointList.RemoveAll();
	tmpsegment.m_nIndex=0;
	tmpsegment.m_bIsVisited=false;
	tmpsegment.m_bCreatDirection=true;
	tmpsegment.m_nSegmentTotalNumber=0;
	tmpmyarray.Add(tmpsegment); <-- remove this compile ok!

the compile output

------ Build started: Project: maxborder, Configuration: Debug Win32 ------
Compiling...
maxborder.cpp
maxborderView.cpp
c:\program files\microsoft visual studio
8\vc\atlmfc\include\afxtempl.h(781) : error C2248: 'CObject::CObject' :
cannot

access private member declared in class 'CObject'
        c:\program files\microsoft visual studio
8\vc\atlmfc\include\afx.h(553) : see declaration of 'CObject::CObject'
        c:\program files\microsoft visual studio
8\vc\atlmfc\include\afx.h(524) : see declaration of 'CObject'
        This diagnostic occurred in the compiler generated function
'CList<TYPE,ARG_TYPE>::CList(const CList<TYPE,ARG_TYPE>

&)'
        with
        [
            TYPE=CMyPoint,
            ARG_TYPE=CMyPoint
        ]
Segment.cpp
Generating Code...
Build log was saved at "file://c:\Documents and Settings\fc\\
borderlast\maxborder\maxborder\Debug\BuildLog.htm"
maxborder - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

What is wrong with my code? Help me!
Thanks a lot.

7. faq can not add Template declarations

8. faq how to size dialog box

Hi,
   I have a mfc windows programme base on a dialog. Now I want to chang the
size of the dialog 320x240 to 1024x768 when it star to run and center it.
How should I do?
   Thanks.