Hi,
I have an MDI App. I have a doc and view opened displaying some data.
Now in my menu I have a View->Plot item (ID_VIEW_PLOT) clicking on
which a new window (popup) will open on which I can display a graph.
To display a graph i need a CFormView derived view window which gets
displayed on clicking View->Plot. Can anyone detail me out how i can
do
this.I have the code to display charts but i need the way to create a
popup which uses my CFormView derived class to display the pop up
dialog. I need to have the handler for ID_VIEW_PLOT in CFormView
derived class and not in CWinApp nor in CMyAppView class. I want 2
type of view classes wherein the form view opens only if i click the
menu item.
Thanx in advance.

Re: Creating Popups and Display Graph by David

David
Wed Jul 25 12:36:18 CDT 2007

>I have an MDI App. I have a doc and view opened displaying some data.
>Now in my menu I have a View->Plot item (ID_VIEW_PLOT) clicking on
>which a new window (popup) will open on which I can display a graph.
>To display a graph i need a CFormView derived view window which gets
>displayed on clicking View->Plot. Can anyone detail me out how i can
>do this.

I'm not aware of any sample that's a perfect match for what you want,
but the VIEWEX sample might illustrate the sorts of things that you
would need for multiple views.

Dave

Re: Creating Popups and Display Graph by rishabh

rishabh
Thu Jul 26 01:19:58 CDT 2007

On Jul 25, 10:36 pm, David Lowndes <Dav...@example.invalid> wrote:
> >I have an MDI App. I have a doc and view opened displaying some data.
> >Now in my menu I have a View->Plot item (ID_VIEW_PLOT) clicking on
> >which a new window (popup) will open on which I can display a graph.
> >To display a graph i need a CFormView derived view window which gets
> >displayed on clicking View->Plot. Can anyone detail me out how i can
> >do this.
>
> I'm not aware of any sample that's a perfect match for what you want,
> but the VIEWEX sample might illustrate the sorts of things that you
> would need for multiple views.
>
> Dave

Thanx for the help Dave,
Well my prob is solved now. I figured it
somehow. But now I have a new prob. Can u help me out? I want to use
the document's data (CAppDoc) in a CDialog derived class(CAppDlg) . In
my CAppView class i can do that by using GetDocument() function but
how do I do it in my new CAppDlg Class. Or is there aby way to read
data from a public member of CAppView class in CAppDlg class. Thanx in
advance


Re: Creating Popups and Display Graph by David

David
Thu Jul 26 02:07:53 CDT 2007

>Thanx for the help Dave,
> Well my prob is solved now. I figured it
>somehow. But now I have a new prob. Can u help me out? I want to use
>the document's data (CAppDoc) in a CDialog derived class(CAppDlg) . In
>my CAppView class i can do that by using GetDocument() function but
>how do I do it in my new CAppDlg Class.

I'd add a CMyDocument * member variable to the dialog class and pass
the document (pointer) as a parameter in the dialog's constructor. If
you create the dialog from your CMyView class you'd pass the return
value from GetDocument(), if you create the dialog from your
CMyDocument class pass "this".

Dave

Re: Creating Popups and Display Graph by rishabh

rishabh
Thu Jul 26 03:56:02 CDT 2007

Thanx for the solution Dave. But the problem still persists. I will
detail it out now.

I have created a Modeless Dialog Box using threads (CWinThread). The
thread invokes a dialog box (derived from CDialog) which acts as
modeless. The thread is invoked through a menu handler in CMyView
class. Now in my dialog box that is invoked in Cwinthread derived
class , i want my doc or view data to be there. Now can u tell me how
can i do that.

I tried this but the execution terminates abnormally. I placed a
static function in CMyDoc to return a pointer to the active document.
In this function i used AfxGetApp() to get m_pMainWnd and then
MDIGetActive() to get active frame. I have called this function in my
dialog's OnInitDialog() function. It is the MDIGetActive() that is
causing abnormal execution. Can u help? Code for static function is:

CMDIChildWnd * pChild =
((CMDIFrameWnd*)(AfxGetApp()->m_pMainWnd))->MDIGetActive();

if ( !pChild )
return NULL;

CDocument * pDoc = pChild->GetActiveDocument();

if ( !pDoc )
return NULL;

// Fail if doc is of wrong kind
if ( ! pDoc->IsKindOf( RUNTIME_CLASS(CMyDoc) ) )
return NULL;

return (CMyDoc *) pDoc;


Re: Creating Popups and Display Graph by David

David
Thu Jul 26 04:44:51 CDT 2007

>I have created a Modeless Dialog Box using threads (CWinThread).

Eeek - why? There's rarely a good reason to have a multi-threaded UI -
they're *very* difficult to do correctly. I wouldn't ever contemplate
one.

> The
>thread invokes a dialog box (derived from CDialog) which acts as
>modeless. The thread is invoked through a menu handler in CMyView
>class. Now in my dialog box that is invoked in Cwinthread derived
>class , i want my doc or view data to be there. Now can u tell me how
>can i do that.

Eliminate the thread, you've not shown any reason to have it, and
it'll undoubtedly be the source of problems.

>I tried this but the execution terminates abnormally. I placed a
>static function in CMyDoc to return a pointer to the active document.

That sounds odd - surely your CMyDoc is the document?

>In this function i used AfxGetApp() to get m_pMainWnd and then
>MDIGetActive() to get active frame. I have called this function in my
>dialog's OnInitDialog() function.

You're immediately trying to go across UI threads - this will be the
problem.

Dave

Re: Creating Popups and Display Graph by rishabh

rishabh
Thu Jul 26 04:56:03 CDT 2007

Thank u Dave, I also figured out that accessing AfxGetApp()-
>m_pMainWnd from another thread might be causing problems. You are
telling me to eliminate the thread. Then can u tell me how I can
create a modeless dialog box to display data (which is displayed when
i click a menu item - as a popup) without creating another thread.
Please help, this project is eating me alive!!-


Re: Creating Popups and Display Graph by David

David
Thu Jul 26 05:33:05 CDT 2007

rishabh.saxena.iitd@gmail.com wrote:
> Thank u Dave, I also figured out that accessing AfxGetApp()-
>> m_pMainWnd from another thread might be causing problems. You are
> telling me to eliminate the thread. Then can u tell me how I can
> create a modeless dialog box to display data (which is displayed when
> i click a menu item - as a popup) without creating another thread.
> Please help, this project is eating me alive!!-
>

rishabh:

Secondary threads should always use PostMessage() or SendMessage() to
transmit information back to the main GUI thread. Always.

--
David Wilkinson
Visual C++ MVP

Re: Creating Popups and Display Graph by David

David
Thu Jul 26 06:20:46 CDT 2007

>Thank u Dave, I also figured out that accessing AfxGetApp()-
>>m_pMainWnd from another thread might be causing problems. You are
>telling me to eliminate the thread. Then can u tell me how I can
>create a modeless dialog box to display data (which is displayed when
>i click a menu item - as a popup) without creating another thread.

You seem to be confused - there's no reason you need a separate thread
to display a modeless dialog.

Dave

Re: Creating Popups and Display Graph by rishabh

rishabh
Thu Jul 26 06:45:59 CDT 2007

On Jul 26, 4:20 pm, David Lowndes <Dav...@example.invalid> wrote:
> >Thank u Dave, I also figured out that accessing AfxGetApp()-
> >>m_pMainWnd from another thread might be causing problems. You are
> >telling me to eliminate the thread. Then can u tell me how I can
> >create a modeless dialog box to display data (which is displayed when
> >i click a menu item - as a popup) without creating another thread.
>
> You seem to be confused - there's no reason you need a separate thread
> to display a modeless dialog.
>
> Dave

Ya Dave Thank u very much for the support. Not using a new thread has
solved all my problems and now I can proceed. Thanx for bearing wid me.