Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Style MessageBox
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 19-Sep-11 9:54am
Edited 19-Sep-11 11:30am
v3

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
 
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.

}
  Permalink  
v4
Comments
Vijay Pate at 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)

  Print Answers RSS
0 Maciej Los 245
1 OriginalGriff 210
2 Manfred R. Bihy 190
3 CHill60 180
4 _Amy 155
0 OriginalGriff 7,445
1 Sergey Alexandrovich Kryukov 6,157
2 Maciej Los 3,774
3 Peter Leow 3,448
4 CHill60 2,702


Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 20 Sep 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100