4 * Copyright 1997,98 Marcel Baur <mbaur@g26.ethz.ch>
5 * Copyright 1998 Karl Backstr”m <karl_b@geocities.com>
17 CHAR STRING_MENU_Xx
[] = "MENU_Xx";
18 CHAR STRING_PAGESETUP_Xx
[] = "DIALOG_PAGESETUP_Xx";
20 void LANGUAGE_UpdateWindowCaption(void) {
21 /* Sets the caption of the main window according to Globals.szFileName:
22 Notepad - (untitled) if no file is open
23 Notepad - [filename] if a file is given
26 CHAR szCaption
[MAX_STRING_LEN
];
27 CHAR szUntitled
[MAX_STRING_LEN
];
29 LoadString(Globals
.hInstance
, IDS_NOTEPAD
, szCaption
, sizeof(szCaption
));
31 if (strlen(Globals
.szFileName
)>0) {
32 lstrcat(szCaption
, " - [");
33 lstrcat(szCaption
, Globals
.szFileName
);
34 lstrcat(szCaption
, "]");
38 LoadString(Globals
.hInstance
, IDS_UNTITLED
, szUntitled
, sizeof(szUntitled
));
39 lstrcat(szCaption
, " - ");
40 lstrcat(szCaption
, szUntitled
);
43 SetWindowText(Globals
.hMainWnd
, szCaption
);
49 static BOOL
LANGUAGE_LoadStringOther(UINT num
, UINT ids
, LPSTR str
, UINT len
)
53 ids
-= Globals
.wStringTableOffset
;
56 bOk
= LoadString(Globals
.hInstance
, ids
, str
, len
);
63 VOID
LANGUAGE_SelectByName(LPCSTR lang
)
68 for (i
= 0; i
<= MAX_LANGUAGE_NUMBER
; i
++)
69 if (LANGUAGE_LoadStringOther(i
, IDS_LANGUAGE_ID
, newlang
, sizeof(newlang
)) &&
70 !lstrcmp(lang
, newlang
))
72 LANGUAGE_SelectByNumber(i
);
77 for (i
= 0; i
<= MAX_LANGUAGE_NUMBER
; i
++)
78 if (LANGUAGE_LoadStringOther(i
, IDS_LANGUAGE_ID
, newlang
, sizeof(newlang
)))
80 LANGUAGE_SelectByNumber(i
);
84 MessageBox(Globals
.hMainWnd
, "No language found", "FATAL ERROR", MB_OK
);
88 VOID
LANGUAGE_SelectByNumber(UINT num
)
92 CHAR item
[MAX_STRING_LEN
];
95 /* Select string table */
96 Globals
.wStringTableOffset
= num
* 0x100;
99 LoadString(Globals
.hInstance
, IDS_LANGUAGE_ID
, lang
, sizeof(lang
));
100 Globals
.lpszLanguage
= lang
;
102 /* Set frame caption */
103 LANGUAGE_UpdateWindowCaption();
105 /* Change Resource names */
106 lstrcpyn(STRING_MENU_Xx
+ sizeof(STRING_MENU_Xx
) - 3, lang
, 3);
107 lstrcpyn(STRING_PAGESETUP_Xx
+ sizeof(STRING_PAGESETUP_Xx
) - 3, lang
, 3);
110 hMainMenu
= LoadMenu(Globals
.hInstance
, STRING_MENU_Xx
);
111 Globals
.hFileMenu
= GetSubMenu(hMainMenu
, 0);
112 Globals
.hEditMenu
= GetSubMenu(hMainMenu
, 1);
113 Globals
.hSearchMenu
= GetSubMenu(hMainMenu
, 2);
114 Globals
.hLanguageMenu
= GetSubMenu(hMainMenu
, 3);
115 Globals
.hHelpMenu
= GetSubMenu(hMainMenu
, 4);
117 /* Remove dummy item */
118 RemoveMenu(Globals
.hLanguageMenu
, 0, MF_BYPOSITION
);
119 /* Add language items */
120 for (i
= 0; i
<= MAX_LANGUAGE_NUMBER
; i
++)
121 if (LANGUAGE_LoadStringOther(i
, IDS_LANGUAGE_MENU_ITEM
, item
, sizeof(item
)))
122 AppendMenu(Globals
.hLanguageMenu
, MF_STRING
| MF_BYCOMMAND
,
123 NP_FIRST_LANGUAGE
+ i
, item
);
125 SetMenu(Globals
.hMainWnd
, hMainMenu
);
127 /* Destroy old menu */
128 if (Globals
.hMainMenu
) DestroyMenu(Globals
.hMainMenu
);
129 Globals
.hMainMenu
= hMainMenu
;
132 /* Update system menus */
133 for (i
= 0; Languages
[i
].name
&& lstrcmp(lang
, Languages
[i
].name
);) i
++;
134 if (Languages
[i
].name
) Options
.language
= i
;
139 VOID
LANGUAGE_DefaultHandle(WPARAM wParam
)
141 if ((wParam
>=NP_FIRST_LANGUAGE
) && (wParam
<=NP_LAST_LANGUAGE
))
142 LANGUAGE_SelectByNumber(wParam
- NP_FIRST_LANGUAGE
);
143 else printf("Unimplemented menu command %i\n", wParam
);
146 VOID
LANGUAGE_Init(VOID
)
149 Globals
.lpszLanguage
= Languages
[Options
.language
].name
;
151 CHAR buffer
[MAX_PATHNAME_LEN
], *p
;
154 PROFILE_GetWineIniString("programs", "language", "language",
155 buffer
, sizeof(buffer
));
157 Globals
.lpszLanguage
= p
= LocalLock(LocalAlloc(LMEM_FIXED
, lstrlen(buffer
)+1));
159 /* hmemcpy(p, buffer, 1 + lstrlen(buffer)); */