I have some code that looks as follows:
void MyClass::OnButtonClick()
{
int retVal = SomeDialog.DoModal();
if(retVal == MYCLASS_ERROR)
{
MessageBox("Error"...blah ...blah);
}
else if(retVal == IDOK) // IDOK is returned on clicking the 'OK' button
{
MessageBox("All is well"...blah ...blah);
}
}
SomeDialog
just shows a progress bar. On any error, the progress bar is automatically closed by callingEndDialog(MYCLASS_ERROR)
. Only on successful completion will the user be allowed to click on 'OK' there.MYCLASS_ERROR
is a value in anenum
which contains all sorts of return types and statuses.
I found that on clicking OK in SomeDialog
, the error message still displayed! I dug a little deeper and found that MYCLASS_ERROR
= IDOK
= 1.
So my question is, how should I define all these return statuses such that it doesn't collide with any other implementation's statuses? Meaning, my functions should return values that is not returned by any other function (or as few other functions as possible).
I thought of modifying my design such that all functions only returned TRUE or FALSE. But, this would not be feasible in all cases. I have also searched quite a bit for answers and haven't found any thus far.
Thanks for looking!