1 Replies - 9627 Views - Last Post: 23 December 2012 - 06:56 PM

#1 Hooor  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 86
  • Joined: 26-May 11

problem in print preview got an C++ exception: long at memory location

Posted 23 December 2012 - 03:42 PM

I am trying to code the printing part of my code
but before I did any thing when I try to see the print preview of my code I got this exception:

First-chance exception at 0x760cc6e3 (KernelBase.dll) in patron1.exe: Microsoft C++ exception: long at memory location 0x001fe8e0..

I thought that happened because of the mapping mode I used which is MM_LOMETRIC so I add virtual function to define it:
void Cpatron1View::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
{
	pDC->SetMapMode(MM_LOMETRIC);
	
	SetGraphicsMode(NULL,GM_ADVANCED);

	CScrollView::OnPrepareDC(pDC, pInfo);
}



but I also get the same exception

I also try to change the onprepareprinting function definition by
add CDC* pDC as parameter:


BOOL Cpatron1View::OnPreparePrinting(CDC* pDC,CPrintInfo* pInfo)
{
	pDC->SetMapMode(MM_LOMETRIC);
	SetGraphicsMode(NULL,GM_ADVANCED);
	
	return DoPreparePrinting(pInfo);
}





when I did that the exception did not happened but when I click on the print preview the program got Stuck(I do not know I am using the right word but I mean the run got frozen and I can not do anything)


I am using visual studio c++ 2010 to create MFC project

could you please tell me what I did wrong??
thanks alot

Is This A Good Question/Topic? 0
  • +

Replies To: problem in print preview got an C++ exception: long at memory location

#2 jjl  Icon User is offline

  • Engineer
  • member icon

Reputation: 1091
  • View blog
  • Posts: 4,572
  • Joined: 09-June 09

Re: problem in print preview got an C++ exception: long at memory location

Posted 23 December 2012 - 06:56 PM

Your DoPrepareDC calls OnPrepareDC which then calls DoPrepareDC. Do you see the circular dependence?

Your error happens because you are overflowing your stack memory with function calls

This post has been edited by jjl: 23 December 2012 - 06:57 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1