I think there is someting wrong with this code!

  • Thread starter Thread starter Frank
  • Start date Start date
F

Frank

I'm looking at a program I wrote long ago and I think there is much wrong -
even tho it works.
I know very little c and wish the learn.
Is BOOL correct with a dialog proc!
Are there returns that don't belong there?
Is it correct to sometimes return a BOOL and sometime an int?


int iReply;

iReply = DialogBox(hInstance, "DlgRetrieveSavedGame", hwndMain,
RetrieveSavedProc);

if ( iReply == IDYES )

....snip

BOOL CALLBACK RetrieveSavedProc( HWND hDlg, UINT uMessage, WPARAM wParam,
LPARAM lParam)

{

...snip

case WM_INITDIALOG:

....snip

return TRUE;

case IDCANCEL:

EndDialog( hDlg, IDCANCEL);

return TRUE;

default:

return FALSE;
 
Frank said:
I'm looking at a program I wrote long ago and I think there is much
wrong - even tho it works.
I know very little c and wish the learn.
Is BOOL correct with a dialog proc!

Yes. I think the missing piece of your puzzle is DWL_MSGRESULT. See
http://msdn2.microsoft.com/en-us/library/ms645469.aspx
Are there returns that don't belong there?
No.

Is it correct to sometimes return a BOOL and sometime an int?
No.



int iReply;

iReply = DialogBox(hInstance, "DlgRetrieveSavedGame", hwndMain,
RetrieveSavedProc);

Ok, because DialogBox doesn't return the return value from the dialog
procedure, it returns the value passed to EndDialog.
 
Back
Top