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