Click here to Skip to main content
15,890,717 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working on Project with AfxMessaeBox and MB_OKCANCEL and I need to utilize OK to move to next page and CANCEL to terminate the Application any idea?

Code I wrote so far to accomplish is as follow:

COleDateTime timeStart;
COleDateTimeSpan timePassed; 
int daysLeft = 0;
timeStart = COleDateTime::GetCurrentTime();  
// Date and time of the Installation.
timePassed = COleDateTime::GetCurrentTime( ) - timeStart;
daysLeft = 30 - static_cast< int >( timePassed.GetTotalDays( ) );
CString strMessage; if( daysLeft > 0 )
{
strMessage.Format( "ADDapt was not activated within 30 days of " "installation and is currently not functional.\n" "To activate please call Avtron Field Service at 216-642-1230 begin_of_the_skype_highlighting 216-642-1230 end_of_the_skype_highlighting " "ext 1214.\n" "The 30 days trial period starts on the day you installed " "ADDapt.\n" "You have %d days left to renew ADDapt Software.", daysLeft );
 
}
else
{ 
 strMessage.Format( "ADDapt was not activated within 30 days of "
"installation and is currently not functional.\n"
"To activate please call Avtron Field Service at 216-642-1230 begin_of_the_skype_highlighting 216-642-1230 end_of_the_skype_highlighting "
"ext 1214.\n"
"The 30 days trial period starts on the day you installed "
"ADDapt.\n"
"You have %d days left to renew ADDapt Software.", daysLeft );
}
AfxMessageBox( strMessage, MB_OKCALCEL);
Posted
Updated 19-Sep-11 11:30am
v3

1 solution

The AfxMessageBox[^] return value can be used to determine which button was pressed by the user. When using the style MB_OKCANCEL the function returns IDOK when the OK button is pressed and IDCANCEL when the cancel button is used.

C++
if( AfxMessageBox( strMessage, MB_OKCANCEL) == IDCANCEL )
{
	// Stop application from starting.
	// The way to stop the application depends on the location in the
	// flow the trial check is performed.

}
 
Share this answer
 
v4
Comments
Vijay Pate 20-Sep-11 8:34am    
either way I press ok or cancle it bring main form up.
Thank you for your prompt reply.

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