clean up dialog init

This commit is contained in:
ehouse 2004-05-26 04:46:57 +00:00
parent fa5bdc2457
commit 0a6a9de4cf
3 changed files with 87 additions and 89 deletions

View file

@ -17,8 +17,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifdef XWFEATURE_CE_EDITCOLORS
#include <Windowsx.h> #include <Windowsx.h>
#include "stdafx.h" #include "stdafx.h"
#include <commdlg.h> #include <commdlg.h>
@ -133,7 +131,7 @@ updateForField( HWND hDlg, ClrEditDlgState* eState, XP_U16 fieldID )
} }
} /* updateForField */ } /* updateForField */
static LRESULT CALLBACK LRESULT CALLBACK
EditColorsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) EditColorsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
{ {
ClrEditDlgState* eState; ClrEditDlgState* eState;
@ -151,6 +149,9 @@ EditColorsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
return TRUE; return TRUE;
} else { } else {
eState = (ClrEditDlgState*)GetWindowLong( hDlg, GWL_USERDATA ); eState = (ClrEditDlgState*)GetWindowLong( hDlg, GWL_USERDATA );
if ( !eState ) {
return FALSE;
}
if ( !eState->inited ) { if ( !eState->inited ) {
/* set to true first! Messages will be generated by /* set to true first! Messages will be generated by
@ -350,6 +351,7 @@ ColorsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
return TRUE; return TRUE;
} else { } else {
cState = (ColorsDlgState*)GetWindowLong( hDlg, GWL_USERDATA ); cState = (ColorsDlgState*)GetWindowLong( hDlg, GWL_USERDATA );
if ( !!cState ) {
if ( !cState->inited ) { if ( !cState->inited ) {
initColorData( cState, hDlg ); initColorData( cState, hDlg );
@ -387,7 +389,7 @@ ColorsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
return TRUE; return TRUE;
} }
}
} }
} }
@ -415,5 +417,3 @@ ceDoColorsEdit( HWND hwnd, CEAppGlobals* globals, COLORREF* colors )
return !state.cancelled; return !state.cancelled;
} /* ceDoColorsEdit */ } /* ceDoColorsEdit */
#endif

View file

@ -109,10 +109,8 @@ loadStateFromCurPrefs( const CEAppPrefs* appPrefs, const CurGameInfo* gi,
prefsPrefs->showColors = appPrefs->showColors; prefsPrefs->showColors = appPrefs->showColors;
XP_MEMCPY( &prefsPrefs->cp, &appPrefs->cp, sizeof(prefsPrefs->cp) ); XP_MEMCPY( &prefsPrefs->cp, &appPrefs->cp, sizeof(prefsPrefs->cp) );
#ifdef XWFEATURE_CE_EDITCOLORS
XP_MEMCPY( &prefsPrefs->colors, &appPrefs->colors, XP_MEMCPY( &prefsPrefs->colors, &appPrefs->colors,
sizeof(prefsPrefs->colors) ); sizeof(prefsPrefs->colors) );
#endif
} /* loadStateFromCurPrefs */ } /* loadStateFromCurPrefs */
void void
@ -130,10 +128,8 @@ loadCurPrefsFromState( CEAppPrefs* appPrefs, CurGameInfo* gi,
appPrefs->showColors = prefsPrefs->showColors; appPrefs->showColors = prefsPrefs->showColors;
XP_MEMCPY( &appPrefs->cp, &prefsPrefs->cp, sizeof(appPrefs->cp) ); XP_MEMCPY( &appPrefs->cp, &prefsPrefs->cp, sizeof(appPrefs->cp) );
#ifdef XWFEATURE_CE_EDITCOLORS
XP_MEMCPY( &appPrefs->colors, &prefsPrefs->colors, XP_MEMCPY( &appPrefs->colors, &prefsPrefs->colors,
sizeof(prefsPrefs->colors) ); sizeof(prefsPrefs->colors) );
#endif
} /* loadCurPrefsFromState */ } /* loadCurPrefsFromState */
/* Reflect local state into the controls user will see. /* Reflect local state into the controls user will see.
@ -231,6 +227,7 @@ PrefsDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
} else { } else {
XP_Bool timerOn; XP_Bool timerOn;
pState = (CePrefsDlgState*)GetWindowLong( hDlg, GWL_USERDATA ); pState = (CePrefsDlgState*)GetWindowLong( hDlg, GWL_USERDATA );
if ( !!pState ) {
globals = pState->globals; globals = pState->globals;
switch (message) { switch (message) {
@ -249,13 +246,11 @@ PrefsDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
0, 0 ); 0, 0 );
setTimerCtls( hDlg, timerOn ); setTimerCtls( hDlg, timerOn );
break; break;
#ifdef XWFEATURE_CE_EDITCOLORS
case IDC_PREFCOLORS: case IDC_PREFCOLORS:
pState->colorsChanged = pState->colorsChanged =
ceDoColorsEdit( hDlg, pState->globals, ceDoColorsEdit( hDlg, pState->globals,
pState->prefsPrefs.colors ); pState->prefsPrefs.colors );
break; break;
#endif
case IDOK: case IDOK:
ceControlsToPrefs( hDlg, &pState->prefsPrefs ); ceControlsToPrefs( hDlg, &pState->prefsPrefs );
case IDCANCEL: case IDCANCEL:
@ -265,6 +260,7 @@ PrefsDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
} }
} }
} }
}
return FALSE; return FALSE;
} /* PrefsDlg */ } /* PrefsDlg */

View file

@ -77,6 +77,7 @@ StrBox(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
} else { } else {
init = (StrBoxInit*)GetWindowLong( hDlg, GWL_USERDATA ); init = (StrBoxInit*)GetWindowLong( hDlg, GWL_USERDATA );
if ( !!init ) {
switch (message) { switch (message) {
case WM_COMMAND: case WM_COMMAND:
@ -97,5 +98,6 @@ StrBox(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
break; break;
} }
} }
}
return FALSE; return FALSE;
} /* StrBox */ } /* StrBox */