Click here to Skip to main content
15,868,077 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
i am facing a problem in following code, iam getting error in PostQuitMessage(0)
0xC0000005: Access violation reading location 0x00000000.

void CARODlg::ShowExitDialogAndQuit(void)
{

if ( !theApp.bIsSavedData)
{
	SetTimer(TIMER_SHOW_SAVEDATA_NAG, nNag_Time, 0) ;
	return;
}
       theApp.AddToLog(_T("PostQuitMessage : ShowExitDialog" )); 
	DestroyWindow();
	PostQuitMessage(0);
}


What I have tried:

iam not getting solution of this error, plz help
Posted
Updated 3-Dec-20 5:17am

Doing some stuff before PostQuitMessage(0) isnt good. When you write a log than flush() the data out to disk and close the file at first.
And you shouldnt call DestroyWindows()
 
Share this answer
 
C++
DestroyWindow();  // this will likely destroy the message pump in your main window
PostQuitMessage(0); // this will try to post a message in a Window that no longer exists.

You should only call PostQuitMessage in response to a WM_DESTROY message. That way it can be actioned before the Window is finally destroyed.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900