Originally posted by: NgHwan Kim
I made a ActiveX control and so there is no frame window.
I added codes in this article except some frame related codes and it worked well first time.
But some memory leaks occured in MFC source code. MFC library codes didn't free memory used for registering document template.
Originally posted by: Mark Ebersole
LINK : fatal error LNK1104: cannot open file "mfc42u.lib"
When trying to build this program I get a fatal Link error.
Originally posted by: Victor Vat
At first, thanks for great article...
When I compile at Release configuration - all works perfectly.
But, when I compile at Debug configuration - appears error
when I press button "Print" in Preview window.
My enviroment -VC6 Win98.
Last error messages at debug window:
"ASSERT_VALID fails with illegal vtable pointer."
"First-chance exception in GridCtrlDemo.exe (KERNEL32.DLL): 0xC0000005: Access Violation."
Stack state listed below:
('->' means trace cursor)
AfxAssertValidObject
{
...
// check to make sure the VTable pointer is valid
ASSERT(sizeof(CObject) == sizeof(void*));
if (!AfxIsValidAddress(*(void**)pOb, sizeof(void*), FALSE))
{
TRACE0("ASSERT_VALID fails with illegal vtable pointer.\n");
if (AfxAssertFailedLine(lpszFileName, nLine))
-> AfxDebugBreak();
return; // quick escape
}
...
}
CCmdTarget::GetRoutingFrame_()
{
CFrameWnd* pFrame = AfxGetThreadState()->m_pRoutingFrame;
if (pFrame != NULL)
-> ASSERT_VALID(pFrame);
return pFrame;
}
CWnd::GetSafeOwner_(HWND hParent, HWND* pWndTop)
{
// get window to start with
HWND hWnd = hParent;
if (hWnd == NULL)
{
-> CFrameWnd* pFrame = CCmdTarget::GetRoutingFrame_();
if (pFrame != NULL)
hWnd = pFrame->GetSafeHwnd();
else
hWnd = AfxGetMainWnd()->GetSafeHwnd();
}
...
}
HWND CDialog::PreModal()
{
...
// find parent HWND
-> HWND hWnd = CWnd::GetSafeOwner_(m_pParentWnd->GetSafeHwnd(), &m_hWndTop);
...
}
int CPrintDialog::DoModal()
{
ASSERT_VALID(this);
-> m_pd.hwndOwner = PreModal();
int nResult = ::PrintDlg(&m_pd);
PostModal();
return nResult ? nResult : IDCANCEL;
}
void CGridCtrl::Print()
{
CDC dc;
CPrintDialog printDlg(FALSE);
-> if (printDlg.DoModal() != IDOK) // Get printer settings from user
return;
...
}
What I must do?
Thanks for help.
Best regards,
Victor Vat.
Originally posted by: Chandrasekhar M.
What is the method to handle the controls in the Preview window (AFX_ID_PREVIEW_NEXT, AFX_ID_PREVIEW_PANE, AFX_ID_PREVIEW_ZOOMIN, AFX_ID_PREVIEW_ZOOMOUT)
ReplyOriginally posted by: Tim Smith
If I use a CPageSetupDialog, how do I set the print preview's page dimensions to the ones stored in the m_psd member?
Thank you very much for any help.
ReplyOriginally posted by: Alessandro Apostoli
Hi,
great idea...
...but I just can't catch the "print" button...
I created the temporary CView object inside a CPropertySheet derived class the way you described in your article but tought I put the correct ON_COMMAND() macros in my PropSheet class I can in no way intercept the ID_FILE_PRINT message.
I am clueless...I tried to catch the message in the temp CView derived class I use for the preview trick but with no success, it even bypasses the PreTranslateMessage()..
The sample you provide works fine, the problem might be the prop sheet...
Thanks in advance
ReplyOriginally posted by: StormCld
hi.
I'm using this class very useful.
thanks for this.
but some problem with working child dialogs.
I made dialog projects that has 3 child dialogs
with modeless, and each child dialogs has print module.
and I want to send ID_FILE_PRINT to child dialogs,
but could not well. ID_FILE_PRINT msg only sent to
the main dialog. so I tried to send some different msg
to main dialog for child dialogs. here is a cheap code.
BOOL CViewPrintPreview::PreTranslateMessage(MSG* pMsg)
{
if( pMsg->message == WM_COMMAND )
{
if( pMsg->wParam == ID_FILE_PRINT )
{
// some process for child dialogs.
}
}
}
but I could not receive any msg.
what is wrong?
May I have any helps?
Originally posted by:
Reply
Originally posted by: Liang Wang
The CDC::SelectObject() requires m_hDC and m_hAttributeDC are the same. How to solve it?
ReplyOriginally posted by: No�mio Ramos
Not compiled in Static Lib