Select current locale, not always first.

This commit is contained in:
ehouse 2009-05-09 18:29:36 +00:00
parent a6ecdd0f9e
commit e55d1528b1

View file

@ -26,7 +26,8 @@ ceLoadResFile( const XP_UCHAR* file )
{ {
HINSTANCE hinst = NULL; HINSTANCE hinst = NULL;
wchar_t widebuf[128]; wchar_t widebuf[128];
XP_U16 len = MultiByteToWideChar( CP_ACP, 0, file, -1, widebuf, VSIZE(widebuf) ); XP_U16 len = MultiByteToWideChar( CP_ACP, 0, file, -1, widebuf,
VSIZE(widebuf) );
widebuf[len] = 0; widebuf[len] = 0;
hinst = LoadLibrary( widebuf ); hinst = LoadLibrary( widebuf );
return hinst; return hinst;
@ -159,6 +160,7 @@ ceFreeResStrings( CEAppGlobals* globals )
typedef struct _DllSelState { typedef struct _DllSelState {
CeDlgHdr dlgHdr; CeDlgHdr dlgHdr;
wchar_t wbuf[MAX_PATH]; wchar_t wbuf[MAX_PATH];
const wchar_t* curFile;
wchar_t* names[8]; wchar_t* names[8];
wchar_t* files[8]; wchar_t* files[8];
@ -189,6 +191,7 @@ listDlls( DllSelState* state )
WIN32_FIND_DATA data; WIN32_FIND_DATA data;
CEAppGlobals* globals = state->dlgHdr.globals; CEAppGlobals* globals = state->dlgHdr.globals;
XP_U16 nItems = 0; XP_U16 nItems = 0;
XP_S16 selIndex = 0; /* default to built-in */
wchar_t name[64]; wchar_t name[64];
LoadString( globals->hInst, IDS_LANGUAGE_NAME, name, VSIZE(name) ); LoadString( globals->hInst, IDS_LANGUAGE_NAME, name, VSIZE(name) );
@ -208,11 +211,17 @@ listDlls( DllSelState* state )
if ( !!hinst ) { if ( !!hinst ) {
if ( LoadString( hinst, IDS_LANGUAGE_NAME, if ( LoadString( hinst, IDS_LANGUAGE_NAME,
name, VSIZE(name) ) ) { name, VSIZE(name) ) ) {
(void)SendDlgItemMessage( hDlg, state->dllListID, ADDSTRING(globals), (void)SendDlgItemMessage( hDlg, state->dllListID,
0, (LPARAM)name ); ADDSTRING(globals), 0, (LPARAM)name );
copyWideStr( globals, name, &state->names[nItems] ); copyWideStr( globals, name, &state->names[nItems] );
copyWideStr( globals, data.cFileName, &state->files[nItems] ); copyWideStr( globals, data.cFileName, &state->files[nItems] );
if ( !!state->curFile ) {
if ( !wcscmp( data.cFileName, state->curFile ) ) {
selIndex = nItems;
}
}
++nItems; ++nItems;
} else { } else {
XP_LOGF( "IDS_LANGUAGE_NAME not found in %ls", data.cFileName ); XP_LOGF( "IDS_LANGUAGE_NAME not found in %ls", data.cFileName );
@ -230,7 +239,8 @@ listDlls( DllSelState* state )
break; break;
} }
} }
SendDlgItemMessage( hDlg, state->dllListID, SETCURSEL(globals), 0, 0 ); SendDlgItemMessage( hDlg, state->dllListID, SETCURSEL(globals),
selIndex, 0L );
state->nItems = nItems; state->nItems = nItems;
LOG_RETURN_VOID(); LOG_RETURN_VOID();
@ -324,12 +334,20 @@ XP_Bool
ceChooseResFile( CEAppGlobals* globals, XP_UCHAR* buf, XP_U16 bufLen ) ceChooseResFile( CEAppGlobals* globals, XP_UCHAR* buf, XP_U16 bufLen )
{ {
DllSelState state; DllSelState state;
wchar_t curFile[MAX_PATH];
XP_MEMSET( &state, 0, sizeof(state) ); XP_MEMSET( &state, 0, sizeof(state) );
state.dlgHdr.globals = globals; state.dlgHdr.globals = globals;
(void)DialogBoxParam( globals->locInst, (LPCTSTR)IDD_LOCALESDLG, globals->hWnd, if ( globals->langFileName ) {
(DLGPROC)DllSelDlg, (long)&state ); (void)MultiByteToWideChar( CP_ACP, 0, globals->langFileName, -1,
curFile, VSIZE(curFile) );
state.curFile = curFile;
}
(void)DialogBoxParam( globals->locInst, (LPCTSTR)IDD_LOCALESDLG,
globals->hWnd, (DLGPROC)DllSelDlg, (long)&state );
if ( !state.cancelled ) { if ( !state.cancelled ) {
(void)WideCharToMultiByte( CP_ACP, 0, state.wbuf, -1, (void)WideCharToMultiByte( CP_ACP, 0, state.wbuf, -1,