Migration of Print Preview code from VC++ 6.0 to VC++ 2008
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 23

Thread: Migration of Print Preview code from VC++ 6.0 to VC++ 2008

  1. #1
    Join Date
    Oct 2003
    Location
    Bangalore
    Posts
    25

    Red face Migration of Print Preview code from VC++ 6.0 to VC++ 2008

    Hi,
    I am migrating my project from VC++ 6.0 to VC++ 2008.I have been successful in doing so until now,where I am stuck up with Priint Preview part of the project.I have googled for this, and made some changes to my code.I find no compilation errors in the code,but The Print Preview editor doesn't launches itself.
    I found that,making

    CPrintDocument::IsPrintPreview_S()

    forcefully false in the code while running,launches the Print Preview editor after some assertions.It launches with inaccuracies in the display.i.e., Scrollbar is not moving properly and others.

    As I said before,I have made these following code changes,

    CWnd* pMainWnd = GetParentFrame();
    if (DYNAMIC_DOWNCAST(CFrameWnd, pMainWnd) == NULL)
    {
    // if it's not a frame, we'll try the main window
    pMainWnd = AfxGetMainWnd();
    }

    CFrameWnd* pParent = STATIC_DOWNCAST(CFrameWnd, pMainWnd);

    CWnd* pToolBar = pParent->GetDlgItem(AFX_IDW_PREVIEW_BAR);

    Thanks to anyone who helps me in this.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,301

    Re: Migration of Print Preview code from VC++ 6.0 to VC++ 2008

    Quote Originally Posted by deepakbidap View Post
    I found that,making

    CPrintDocument::IsPrintPreview_S()

    forcefully false in the code while running,launches the Print Preview editor after some assertions.It launches with inaccuracies in the display.i.e., Scrollbar is not moving properly and others.

    As I said before,I have made these following code changes,
    What is CPrintDocument?
    What is IsPrintPreview_S()?
    Why did you make "code changes" in a working project?
    Victor Nijegorodov

  3. #3
    Join Date
    Oct 2003
    Location
    Bangalore
    Posts
    25

    Re: Migration of Print Preview code from VC++ 6.0 to VC++ 2008

    CPrintdocument is a user defined class,sorry I thought it is one of those MFC classes.
    static BOOL IsPrintPreview_S(); is the member function of CPrintdocument.
    The code is from VC++ 6.0 where it is working,so after converting it to a VC++ 2008 project,it had compilation errors.So I had to make the above mentioned code changes.

  4. #4
    Join Date
    Oct 2003
    Location
    Bangalore
    Posts
    25

    Re: Migration of Print Preview code from VC++ 6.0 to VC++ 2008

    COleIPFrameWnd *pInPlaceFrame = DYNAMIC_DOWNCAST(COleIPFrameWnd, pParentFrame);

    in Viewprev.cpp.
    Here pInPlaceFrame=0x00000000

    But in VC++ 6.0,Viewprev.cpp,
    this class is not called.

  5. #5
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,301

    Re: Migration of Print Preview code from VC++ 6.0 to VC++ 2008

    Quote Originally Posted by deepakbidap View Post
    The code is from VC++ 6.0 where it is working,so after converting it to a VC++ 2008 project,it had compilation errors.
    What (exactly) is the code that has compilation errors? What are those errors?
    Victor Nijegorodov

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,301

    Re: Migration of Print Preview code from VC++ 6.0 to VC++ 2008

    Quote Originally Posted by deepakbidap View Post
    COleIPFrameWnd *pInPlaceFrame = DYNAMIC_DOWNCAST(COleIPFrameWnd, pParentFrame);

    in Viewprev.cpp.
    Here pInPlaceFrame=0x00000000
    But you wrote the code has compilation errors!
    So does it copile or not?

    Quote Originally Posted by deepakbidap View Post
    But in VC++ 6.0,Viewprev.cpp,
    this class is not called.
    Which class "is not called"?
    Victor Nijegorodov

  7. #7
    Join Date
    Oct 2003
    Location
    Bangalore
    Posts
    25

    Re: Migration of Print Preview code from VC++ 6.0 to VC++ 2008

    Original code,
    CPreviewView* pPreviewView = DYNAMIC_DOWNCAST(CPreviewView, pMainFrame->GetDlgItem(AFX_IDW_PANE_FIRST));
    CWnd* pToolBar = pMainFrame->GetDlgItem(AFX_IDW_PREVIEW_BAR);

    Here during debugging,found that,

    pPreviewView=0x00000000
    pToolBar=0x00000000

    Hence giving exception elsewhere,
    Unhandled exception at (mfc90d.dll)

  8. #8
    Join Date
    Oct 2003
    Location
    Bangalore
    Posts
    25

    Re: Migration of Print Preview code from VC++ 6.0 to VC++ 2008

    before these two lines,
    CFrameWnd* pMainFrame = DYNAMIC_DOWNCAST(CFrameWnd, AfxGetMainWnd());

    Hence corrected to,
    CWnd* pMainWnd = GetParentFrame();
    if (DYNAMIC_DOWNCAST(CFrameWnd, pMainWnd) == NULL)
    {
    // if it's not a frame, we'll try the main window
    pMainWnd = AfxGetMainWnd();
    }

    CFrameWnd* pParent = STATIC_DOWNCAST(CFrameWnd, pMainWnd);
    CPreviewView* pPreviewView = DYNAMIC_DOWNCAST(CPreviewView, pParent->GetDlgItem(AFX_IDW_PANE_FIRST));


    CWnd* pToolBar=(CWnd*) pParent->GetDlgItem(AFX_IDW_PREVIEW_BAR);

  9. #9
    Join Date
    Apr 1999
    Posts
    27,423

    Re: Migration of Print Preview code from VC++ 6.0 to VC++ 2008

    I have never used Print Preview, but I have some comments and questions:
    Quote Originally Posted by deepakbidap View Post
    I have googled for this,
    Why not just debug to see why the window doesn't open? I don't get why a lot of people think "googling" is supposed to replace the debugger.
    and made some changes to my code.I find no compilation errors in the code,but The Print Preview editor doesn't launches itself.
    Do you know why you made those changes, or you just made changes to make the code compile?

    According to your changes (please use code tags when posting code), you changed much more than just to get the program to compile. If you were making changes due to differences in the C++ language between VC 6 and VC 2008, that's one thing. However, you didn't make this type of change -- you changed the way the program works by pointing to a different window -- that is a different type of "change" altogether. Do you know what the implications are of doing this?

    Regards,

    Paul McKenzie

  10. #10
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,301

    Re: Migration of Print Preview code from VC++ 6.0 to VC++ 2008

    Quote Originally Posted by deepakbidap View Post
    Original code,
    Code:
        CPreviewView* pPreviewView = DYNAMIC_DOWNCAST(CPreviewView, pMainFrame->GetDlgItem(AFX_IDW_PANE_FIRST));
        ...
    Here during debugging,found that,

    pPreviewView=0x00000000
    And what did pMainFrame->GetDlgItem(AFX_IDW_PANE_FIRST) return?
    Victor Nijegorodov

  11. #11
    Join Date
    Oct 2003
    Location
    Bangalore
    Posts
    25

    Re: Migration of Print Preview code from VC++ 6.0 to VC++ 2008

    Name:  image.JPG
Views: 32
Size:  51.2 KB

  12. #12
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,301

    Re: Migration of Print Preview code from VC++ 6.0 to VC++ 2008

    I do NOT see the answer to mz question: what is the return value of
    Code:
    pMainFrame->GetDlgItem(AFX_IDW_PANE_FIRST);
    Victor Nijegorodov

  13. #13
    Join Date
    Oct 2003
    Location
    Bangalore
    Posts
    25

    Re: Migration of Print Preview code from VC++ 6.0 to VC++ 2008

    Name:  pane_rvalue.JPG
Views: 43
Size:  50.8 KB

  14. #14
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,301

    Re: Migration of Print Preview code from VC++ 6.0 to VC++ 2008

    1. Please, always use Code tags while posting code snippets.
    2. Please, don't post screenshots, if no one asked it. It is very hard to "read"/find any useful info from such a picture, especially if one looks for variable values or function return valus.
    3. It is also very hard to discuss your problem with you since you post new variant of your code in every new post!


    Well, could you create a very small test project that can reproduce your problem and post it in a zip archive? Then we'd try to investigate it with debugger to understand what happens.
    Please, do not include debug/relese folder nor .aps, .ncb, .res, .opt files.
    Victor Nijegorodov

  15. #15
    Join Date
    Oct 2003
    Location
    Bangalore
    Posts
    25

    Re: Migration of Print Preview code from VC++ 6.0 to VC++ 2008

    I need time to create the project.Please give me one day's time.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center