clean up dialog init

This commit is contained in:
ehouse 2004-05-26 04:39:29 +00:00
parent 047b85624b
commit 621dd87d71
3 changed files with 106 additions and 101 deletions

View file

@ -54,22 +54,24 @@ PasswdDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
return TRUE; return TRUE;
} else { } else {
pState = (PasswdDialogState*)GetWindowLong( hDlg, GWL_USERDATA ); pState = (PasswdDialogState*)GetWindowLong( hDlg, GWL_USERDATA );
globals = pState->globals; if ( !!pState ) {
globals = pState->globals;
switch ( message ) { switch ( message ) {
case WM_COMMAND: case WM_COMMAND:
id = LOWORD(wParam); id = LOWORD(wParam);
switch( id ) { switch( id ) {
case IDOK: case IDOK:
ceGetDlgItemText( hDlg, PASS_EDIT, pState->buf, pState->lenp ); ceGetDlgItemText( hDlg, PASS_EDIT, pState->buf,
case IDCANCEL: pState->lenp );
pState->userCancelled = id == IDCANCEL; case IDCANCEL:
EndDialog( hDlg, id ); pState->userCancelled = id == IDCANCEL;
EndDialog( hDlg, id );
return TRUE; return TRUE;
}
} }
} }
} }
return FALSE; return FALSE;
} /* PasswdDlg */ } /* PasswdDlg */

View file

@ -108,31 +108,32 @@ BlankDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
loadLettersList( hDlg, bState ); loadLettersList( hDlg, bState );
} else { } else {
bState = (BlankDialogState*)GetWindowLong( hDlg, GWL_USERDATA ); bState = (BlankDialogState*)GetWindowLong( hDlg, GWL_USERDATA );
if ( !!bState ) {
switch (message) { switch ( message ) {
case WM_KEYDOWN: /* key down. Select a list item? */ case WM_KEYDOWN: /* key down. Select a list item? */
XP_LOGF( "got WM_KEYDOWN" ); XP_LOGF( "got WM_KEYDOWN" );
break;
case WM_COMMAND:
id = LOWORD(wParam);
if ( 0 ) {
#ifdef FEATURE_TRAY_EDIT
} else if ( id == IDC_PICKALL ) {
bState->result = PICKER_PICKALL;
} else if ( id == IDC_BACKUP ) {
bState->result = PICKER_BACKUP;
#endif
} else if ( id == IDOK ) {
bState->result =
(XP_S16)SendDlgItemMessage( hDlg, BLANKFACE_LIST,
LB_GETCURSEL, 0, 0 );
} else {
break; break;
case WM_COMMAND:
id = LOWORD(wParam);
if ( 0 ) {
#ifdef FEATURE_TRAY_EDIT
} else if ( id == IDC_PICKALL ) {
bState->result = PICKER_PICKALL;
} else if ( id == IDC_BACKUP ) {
bState->result = PICKER_BACKUP;
#endif
} else if ( id == IDOK ) {
bState->result =
(XP_S16)SendDlgItemMessage( hDlg, BLANKFACE_LIST,
LB_GETCURSEL, 0, 0 );
} else {
break;
}
EndDialog( hDlg, id );
return TRUE;
} }
EndDialog( hDlg, id );
return TRUE;
} }
} }
return FALSE; return FALSE;

View file

@ -359,6 +359,7 @@ handleOptionsButton( HWND hDlg, CEAppGlobals* globals, GameInfoState* giState )
if ( WrapPrefsDialog( hDlg, globals, &state, &giState->prefsPrefs, if ( WrapPrefsDialog( hDlg, globals, &state, &giState->prefsPrefs,
giState->isNewGame ) ) { giState->isNewGame ) ) {
giState->prefsChanged = XP_TRUE; giState->prefsChanged = XP_TRUE;
giState->colorsChanged = state.colorsChanged;
/* nothing to do until user finally does confirm the parent dialog */ /* nothing to do until user finally does confirm the parent dialog */
} }
} /* handleOptionsButton */ } /* handleOptionsButton */
@ -424,92 +425,93 @@ GameInfo(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
} else { } else {
giState = (GameInfoState*)GetWindowLong( hDlg, GWL_USERDATA ); giState = (GameInfoState*)GetWindowLong( hDlg, GWL_USERDATA );
globals = giState->globals; if ( !!giState ) {
globals = giState->globals;
switch (message) { switch (message) {
case WM_COMMAND: case WM_COMMAND:
id = LOWORD(wParam); id = LOWORD(wParam);
switch( id ) { switch( id ) {
case ROBOT_CHECK1: case ROBOT_CHECK1:
case ROBOT_CHECK2: case ROBOT_CHECK2:
case ROBOT_CHECK3: case ROBOT_CHECK3:
case ROBOT_CHECK4: case ROBOT_CHECK4:
ceAdjustVisibility( hDlg, giState, XP_TRUE ); ceAdjustVisibility( hDlg, giState, XP_TRUE );
break; break;
#ifndef XWFEATURE_STANDALONE_ONLY #ifndef XWFEATURE_STANDALONE_ONLY
case REMOTE_CHECK1: case REMOTE_CHECK1:
case REMOTE_CHECK2: case REMOTE_CHECK2:
case REMOTE_CHECK3: case REMOTE_CHECK3:
case REMOTE_CHECK4: case REMOTE_CHECK4:
XP_ASSERT( giState->curServerHilite == SERVER_ISSERVER ); XP_ASSERT( giState->curServerHilite == SERVER_ISSERVER );
on = ceGetChecked( hDlg, id ); on = ceGetChecked( hDlg, id );
ceAdjustVisibility( hDlg, giState, XP_FALSE ); ceAdjustVisibility( hDlg, giState, XP_FALSE );
break; break;
#endif #endif
case IDC_NPLAYERSCOMBO: case IDC_NPLAYERSCOMBO:
if ( HIWORD(wParam) == CBN_SELCHANGE ) { if ( HIWORD(wParam) == CBN_SELCHANGE ) {
if ( giState->isNewGame ) { /* ignore if in info mode */ if ( giState->isNewGame ) { /* ignore if in info mode */
XP_U16 role; XP_U16 role;
XP_U16 sel; XP_U16 sel;
sel = (XP_U16)SendDlgItemMessage( hDlg, sel = (XP_U16)SendDlgItemMessage( hDlg,
IDC_NPLAYERSCOMBO, IDC_NPLAYERSCOMBO,
CB_GETCURSEL, 0, 0L); CB_GETCURSEL, 0, 0L);
++sel; ++sel;
role = (XP_U16)SendDlgItemMessage( hDlg, IDC_ROLECOMBO, role = (XP_U16)SendDlgItemMessage( hDlg, IDC_ROLECOMBO,
CB_GETCURSEL, 0, 0L); CB_GETCURSEL, 0, 0L);
ceAdjustVisibility( hDlg, giState, XP_TRUE ); ceAdjustVisibility( hDlg, giState, XP_TRUE );
}
} }
} break;
break;
case IDC_ROLECOMBO: case IDC_ROLECOMBO:
if ( HIWORD(wParam) == CBN_SELCHANGE ) { if ( HIWORD(wParam) == CBN_SELCHANGE ) {
if ( giState->isNewGame ) { /* ignore if in info mode */ if ( giState->isNewGame ) { /* ignore if in info mode */
XP_U16 sel; XP_U16 sel;
sel = (XP_U16)SendDlgItemMessage( hDlg, IDC_ROLECOMBO, sel = (XP_U16)SendDlgItemMessage( hDlg, IDC_ROLECOMBO,
CB_GETCURSEL, 0, 0L); CB_GETCURSEL, 0, 0L);
giState->curServerHilite = (Connectedness)sel; giState->curServerHilite = (Connectedness)sel;
ceAdjustVisibility( hDlg, giState, XP_FALSE ); ceAdjustVisibility( hDlg, giState, XP_FALSE );
}
} }
} break;
break;
#ifndef STUBBED_DICT #ifndef STUBBED_DICT
case IDC_DICTBUTTON: case IDC_DICTBUTTON:
if ( giState->isNewGame ) { /* ignore if in info mode */ if ( giState->isNewGame ) { /* ignore if in info mode */
giState->newDictName[0] = 0; giState->newDictName[0] = 0;
if ( ce_pickDictFile( globals, giState->newDictName, if ( ce_pickDictFile( globals, giState->newDictName,
sizeof(giState->newDictName) ) ) { sizeof(giState->newDictName) ) ) {
XP_UCHAR* basename = bname(giState->newDictName); XP_UCHAR* basename = bname(giState->newDictName);
ceSetDlgItemFileName( hDlg, id, basename ); ceSetDlgItemFileName( hDlg, id, basename );
}
} }
} break;
break;
#endif #endif
case OPTIONS_BUTTON: case OPTIONS_BUTTON:
handleOptionsButton( hDlg, globals, giState ); handleOptionsButton( hDlg, globals, giState );
break; break;
case IDOK: case IDOK:
stateToGameInfo( hDlg, globals, giState ); stateToGameInfo( hDlg, globals, giState );
case IDCANCEL: case IDCANCEL:
EndDialog(hDlg, id); EndDialog(hDlg, id);
giState->userCancelled = id == IDCANCEL; giState->userCancelled = id == IDCANCEL;
return TRUE; return TRUE;
}
break;
/* case WM_CLOSE: */
/* EndDialog(hDlg, id); */
/* return TRUE; */
/* default: */
/* return DefWindowProc(hDlg, message, wParam, lParam); */
} }
break;
/* case WM_CLOSE: */
/* EndDialog(hDlg, id); */
/* return TRUE; */
/* default: */
/* return DefWindowProc(hDlg, message, wParam, lParam); */
} }
} }
return FALSE; return FALSE;
} /* GameInfo */ } /* GameInfo */