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

View file

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

View file

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