I think there is someting wrong with this code!

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;
 
B

Ben Voigt

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top