-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlanguage.cpp
105 lines (80 loc) · 1.83 KB
/
language.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include "StdAfx.h"
#include "DoHide.h"
#include "globals.h"
#include "resource.h"
const char SZ_LANG_END[] = "*.lng";
/*
*
*
*/
bool LoadLanguageDll( UINT id )
{
WIN32_FIND_DATA wfd;
char s[128];
char fName[MAX_PATH];
GetModuleFileName( hInst, fName, sizeof(fName) );
fName[lstrlen(fName)-4] = 0;
lstrcat(fName,SZ_LANG_END);
HANDLE hFindFile = FindFirstFile( fName, &wfd );
if ( hFindFile==INVALID_HANDLE_VALUE )
return false;
do
{
hResourceInst = LoadLibrary( wfd.cFileName );
if ( hResourceInst!=0 )
{
LoadStr( IDS_LANGUAGE_ID, s, sizeof(s) );
if ( id==(UINT)(s[0]-'0') )
{
FindClose( hFindFile );
return true;
}
FreeLibrary(hResourceInst);
}
}
while ( FindNextFile(hFindFile,&wfd) );
FindClose( hFindFile );
return false;
}
/*
*
*
*/
void FillLanguageComboBox ( HWND hDlg, UINT idLangCombo )
{
WIN32_FIND_DATA wfd;
char s[64];
char fName[MAX_PATH];
GetModuleFileName( hInst, fName, sizeof(fName) );
fName[lstrlen(fName)-4] = 0;
lstrcat(fName,SZ_LANG_END);
HANDLE hFindFile = FindFirstFile( fName, &wfd );
if ( hFindFile==INVALID_HANDLE_VALUE )
return;
HWND hComboWnd = GET(IDC_LANG_COMBO);
do
{
HINSTANCE hLib = LoadLibrary( wfd.cFileName );
LoadString( hLib, IDS_LANGUAGE, s, sizeof(s) );
//int cnt = SendMessage( hComboWnd, CB_GETCOUNT, 0, 0 );
int cnt = SendMessage( hComboWnd, CB_ADDSTRING, 0, (long)s );
LoadString( hLib, IDS_LANGUAGE_ID, s, sizeof(s) );
SendMessage( hComboWnd, CB_SETITEMDATA, cnt, (s[0]-'0') );
FreeLibrary( hLib );
}
while ( FindNextFile(hFindFile,&wfd) );
FindClose( hFindFile );
//
//
//
int cnt = SendMessage( hComboWnd, CB_GETCOUNT, 0, 0 );
for ( int i=0; i<cnt; i++ )
{
UINT id = SendMessage( hComboWnd, CB_GETITEMDATA, i, 0 );
if ( id==uKey[0] )
{
SendMessage( hComboWnd, CB_SETCURSEL, i, 0 );
break;
}
}
}