-
July 16th, 2013, 05:02 AM
#1
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.
-
July 16th, 2013, 05:23 AM
#2
Re: Migration of Print Preview code from VC++ 6.0 to VC++ 2008
Originally Posted by deepakbidap
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
-
July 16th, 2013, 10:26 PM
#3
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.
-
July 17th, 2013, 12:49 AM
#4
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.
-
July 17th, 2013, 02:39 AM
#5
Re: Migration of Print Preview code from VC++ 6.0 to VC++ 2008
Originally Posted by deepakbidap
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
-
July 17th, 2013, 02:41 AM
#6
Re: Migration of Print Preview code from VC++ 6.0 to VC++ 2008
Originally Posted by deepakbidap
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?
Originally Posted by deepakbidap
But in VC++ 6.0,Viewprev.cpp,
this class is not called.
Which class "is not called"?
Victor Nijegorodov
-
July 17th, 2013, 03:16 AM
#7
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)
-
July 17th, 2013, 03:22 AM
#8
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);
-
July 17th, 2013, 04:08 AM
#9
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:
Originally Posted by deepakbidap
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
-
July 17th, 2013, 04:32 AM
#10
Re: Migration of Print Preview code from VC++ 6.0 to VC++ 2008
Originally Posted by deepakbidap
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
-
July 17th, 2013, 05:36 AM
#11
Re: Migration of Print Preview code from VC++ 6.0 to VC++ 2008
-
July 17th, 2013, 05:51 AM
#12
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
-
July 17th, 2013, 10:24 PM
#13
Re: Migration of Print Preview code from VC++ 6.0 to VC++ 2008
-
July 24th, 2013, 05:12 AM
#14
Re: Migration of Print Preview code from VC++ 6.0 to VC++ 2008
- Please, always use Code tags while posting code snippets.
- 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.
- 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
-
July 24th, 2013, 05:19 AM
#15
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|