[vtkusers] RE: *The solution* Re: Access violations in MFC sample

João Filipe de Castro Ferreira jfilipe at isr.uc.pt
Tue Dec 11 10:53:20 EST 2001


Ok! Here are the new versions of OnCreate and OnInitialUpdate for
vtkMFCRenderView:

vtkMFCRenderView.h

<snip>
...

// Operations
public:

...

	virtual void OnInitialUpdate();
<snip>

vtkMFCRenderView.cpp

<snip>
...

int vtkMFCRenderView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (vtkMFCView::OnCreate(lpCreateStruct) == -1)
		return -1;

	// TODO: Add your specialized creation code here
	this->RenderWindow->SetParentId(lpCreateStruct->hwndParent);

	// These are the old declarations which are to be transfered to
OnInitialUpdate()

	//this->RenderWindow->SetWindowId(this->m_hWnd);

	//this->RenderWindow->WindowInitialize();


	return 0;
}

void vtkMFCRenderView::OnInitialUpdate()
{
	vtkMFCView::OnInitialUpdate();

	// TODO: Add your specialized creation code here

	this->RenderWindow->SetWindowId(this->m_hWnd);

	this->RenderWindow->WindowInitialize();
}

...

<snip>

 I am still surprised by the fact that you don't get any warnings of access
violations in your VC++ debugger's output window; of course, if you say so I
believe it - its just that, since I had found similar threads in the
archive, I thought it would be recurring... Sorry about that! :))

										Cheers,
											JFC

-----Mensagem original-----
De: Andrew J. P. Maclean [mailto:a.maclean at acfr.usyd.edu.au]
Enviada: segunda-feira, 10 de Dezembro de 2001 22:07
Para: 'Joao Filipe de Castro Ferreira'
Assunto: RE: *The solution* Re: Access violations in MFC sample


Yes, I would love to see a code snippet. As I have said, I haven't had
nay problems. Especially in relation to access violations.

___________________________________________
Andrew J. P. Maclean
Postal:
Australian Centre for Field Robotics
The Rose Street Building J04
The University of Sydney  2006  NSW
AUSTRALIA
Room:
106
Phone:
+61 2 9351 3283
Fax:
+61 2 9351 7474

http://www.acfr.usyd.edu.au/
___________________________________________


-----Original Message-----
From: Joao Filipe de Castro Ferreira [mailto:jfilipe at isr.uc.pt]
Sent: Tuesday, 11 December 2001 07:23
To: a.maclean at acfr.usyd.edu.au
Cc: vtkusers at public.kitware.com
Subject: *The solution* Re: Access violations in MFC sample

 Dear Andrew,

 I regret to tell you that I used that exact version (which only
corrects
the interactor problem), but the problem remained. The question is, if
you
don't pay attention to your VC++ debugger (not so unusual a thing to
happen ;)) ), you will miss those access violations and the program will
*seem* too work without a problem.

 I have, thus, decided to collect my MFC wits and put them to use to
solve
the problem, which I have noticed by thumbling through the list's
archives
to be a recurring one, and, voila!, have solved it thus:

 The OnCreate override is not the correct place to get
the m_hWnd handle from the *not yet visible* window for the RenderWindow
member. The *correct* procedure is to move the respective line from the
OnCreate override to a newly overriden OnInitialUpdate member, without
forgetting to *call the base class member first*. That's it, really!

 If anybody still has any doubt on this subject, please write and I will
submit code snippets from my own modified MFCSample.


					Cheers,
						JFC


From: a.maclean at acfr.usyd.edu.au

> Get the most recent version of Sample from a nightly download. I have
no
troubles with it.




More information about the vtkusers mailing list