printing in the 2nd view? 
Author Message
 printing in the 2nd view?

I've created a 2nd view for my document. To manage this new view, I
created a new frame PlotFrame(derived from CMDIChildWnd) and a new view
PlotView (derived from CView). The 2nd view will be invoked from a
member function CreateNewFrame() in my only doc class. Everything works
fine except two problems:

1. The print and print preview options were grayed out when I switch the
focus on the 2nd view. I tried to map the IDs to default
CView::OnFilePrint and CView::OnFilePrintPreview or overide them, but
those didn't work.

2. In the new view class I cannot cast the CDocument* to
CMyOneAndOnlyDoc*(causing compile error).
error C2440: 'initializing' : cannot convert from 'class CDocument *' to
'class CMyOneAndOnlyDoc *'
                     Types pointed to are unrelated; conversion requires
reinterpret_cast, C-style cast or function-style cast

 I thought I have attached the doc info to the CCreateContext when I
create this 2nd frame, but the complier didn't think so. Can anyone tell
me where did it go wrong? Thanks.

//PhotodevDoc.cpp

void CMyOneAndOnlyDoc::CreateNewFrame()
{
 pNewFrameContext = new CCreateContext;
 pNewFrameContext->m_pCurrentDoc = this; // the document's pointer
 pNewFrameContext->m_pNewViewClass=RUNTIME_CLASS(PlotView);
 pNewFrame = new PlotFrame;

 RECT rectNewFrame;
 rectNewFrame.left = 100;
 rectNewFrame.top = 100;
 rectNewFrame.right = 400;
 rectNewFrame.bottom = 400;

 pNewFrame -> Create ( NULL,
                        "Analysis result",
                        WS_CHILD | WS_VISIBLE | WS_OVERLAPPEDWINDOW,
                        rectNewFrame,
                        NULL,
                        pNewFrameContext );
 pNewFrame -> ShowWindow ( SW_SHOWNORMAL );
 pNewFrame -> Invalidate ();
 pNewFrame -> UpdateWindow ();

Quote:
}



Sun, 03 Dec 2000 03:00:00 GMT  
 printing in the 2nd view?

    Here is some of my code where I do a similar thing. I do in from
mainframe, but that shouldn't be a problem.

    // Allocate the frame.
    m_pMyFrame = new CMyFrame;

    // Set the frame attributes.
    DWORD dwStyle = WS_CHILD | WS_OVERLAPPED | WS_VISIBLE;
    CRect TempRect(0, 0, 250, 150);
    CCreateContext CreateStruct;
    CreateStruct.m_pNewViewClass = RUNTIME_CLASS(CMyView);
    CreateStruct.m_pCurrentDoc = m_pMyDocument;
    CreateStruct.m_pNewDocTemplate = 0;
    CreateStruct.m_pLastView = 0;
    CreateStruct.m_pCurrentFrame = 0;

    // Create the frame.
    ((CMyFrame *)m_pMyFrame)->Create(0, "", dwStyle, TempRect, 0,
&CreateStruct);

    // Initialize the frame.
   ((CMyFrame *)m_pMyFrame)->InitialUpdateFrame(0, TRUE);

Seems like there are a few differences. (I store m_pMyFrane as a
CMDIChildWnd* so I don't have to have the CMyFrame include in MainFrm.h).
I'm not sure what is causing your problem... - Doug S.

Quote:

> I've created a 2nd view for my document. To manage this new view, I
> created a new frame PlotFrame(derived from CMDIChildWnd) and a new view
> PlotView (derived from CView). The 2nd view will be invoked from a
> member function CreateNewFrame() in my only doc class. Everything works
> fine except two problems:

> 1. The print and print preview options were grayed out when I switch the
> focus on the 2nd view. I tried to map the IDs to default
> CView::OnFilePrint and CView::OnFilePrintPreview or overide them, but
> those didn't work.

> 2. In the new view class I cannot cast the CDocument* to
> CMyOneAndOnlyDoc*(causing compile error).
> error C2440: 'initializing' : cannot convert from 'class CDocument *' to
> 'class CMyOneAndOnlyDoc *'
>                      Types pointed to are unrelated; conversion requires
> reinterpret_cast, C-style cast or function-style cast

>  I thought I have attached the doc info to the CCreateContext when I
> create this 2nd frame, but the complier didn't think so. Can anyone tell
> me where did it go wrong? Thanks.

> //PhotodevDoc.cpp

> void CMyOneAndOnlyDoc::CreateNewFrame()
> {
>  pNewFrameContext = new CCreateContext;
>  pNewFrameContext->m_pCurrentDoc = this; // the document's pointer
>  pNewFrameContext->m_pNewViewClass=RUNTIME_CLASS(PlotView);
>  pNewFrame = new PlotFrame;

>  RECT rectNewFrame;
>  rectNewFrame.left = 100;
>  rectNewFrame.top = 100;
>  rectNewFrame.right = 400;
>  rectNewFrame.bottom = 400;

>  pNewFrame -> Create ( NULL,
>                         "Analysis result",
>                         WS_CHILD | WS_VISIBLE | WS_OVERLAPPEDWINDOW,
>                         rectNewFrame,
>                         NULL,
>                         pNewFrameContext );
>  pNewFrame -> ShowWindow ( SW_SHOWNORMAL );
>  pNewFrame -> Invalidate ();
>  pNewFrame -> UpdateWindow ();
> }



Mon, 04 Dec 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. printing in the 2nd view?

2. Getting 2nd Doc/View data from 1st Doc/View

3. How to display 2nd view, when clicked on 1st view

4. Schildt - 2nd printing/ed

5. Schildt - 2nd printing/edition...

6. Schildt - 2nd printing/ed

7. Printing diff. on 2nd Page

8. Printing different on 2nd page

9. How to print without SDI/MDI (2nd attempt)

10. Adding 2nd view to an SDI

11. 2nd View

12. Accessing Document Data in 2nd View class

 

 
Powered by phpBB® Forum Software