tagging release
[dasher.git] / Src / Win32 / Common / WinLocalisation.cpp
blob63fa3579d3c09a3cfddab14fc98ede41b18036a3
1 // WinLocalisation.cpp
2 //
3 /////////////////////////////////////////////////////////////////////////////
4 //
5 // Copyright (c) 2002 Iain Murray
6 //
7 /////////////////////////////////////////////////////////////////////////////
9 #include "WinCommon.h"
11 #include "WinLocalisation.h"
13 // Track memory leaks on Windows to the line that new'd the memory
14 #ifdef _WIN32
15 #ifdef _DEBUG
16 #define DEBUG_NEW new( _NORMAL_BLOCK, THIS_FILE, __LINE__ )
17 #define new DEBUG_NEW
18 #undef THIS_FILE
19 static char THIS_FILE[] = __FILE__;
20 #endif
21 #endif
23 UINT WinLocalisation::GetUserCodePage() {
24 // Pity this is for the system, not the user:
25 //return GetACP();
27 TCHAR CharCodePage[7];
28 GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IDEFAULTANSICODEPAGE, CharCodePage, 7);
30 return _ttoi(CharCodePage);
33 // // Could get name and other useful stuff about current codepage:
34 // CPINFOEX CPInfoEx;
35 // GetCPInfoEx(CurrentCodePage, 0, &CPInfoEx);
36 // // This Doesn't work in Win95 though...
38 HFONT WinLocalisation::GetCodePageFont(UINT CodePage, LONG Height) {
39 CHARSETINFO CharsetInfo;
40 UINT MyCharset;
41 if(TranslateCharsetInfo((DWORD FAR *) CodePage, &CharsetInfo, TCI_SRCCODEPAGE)) {
42 MyCharset = CharsetInfo.ciCharset;
44 else
45 MyCharset = DEFAULT_CHARSET;
47 return CreateFont(Height, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, MyCharset, // Apart from the character set and size I don't care about the font.
48 OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_DONTCARE, NULL);
51 void WinLocalisation::GetResourceString(UINT ResourceID, Tstring *ResourceString) {
52 const unsigned int MAX_LOADSTRING = 100;
53 TCHAR szTitle[MAX_LOADSTRING];
54 LoadString(WinHelper::hInstApp, ResourceID, szTitle, MAX_LOADSTRING);
55 *ResourceString = szTitle;