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
)
51 ids
-= Globals
.wStringTableOffset
;
53 return(LoadString(Globals
.hInstance
, ids
, str
, len
));
58 VOID
LANGUAGE_SelectByName(LPCSTR lang
)
63 for (i
= 0; i
<= MAX_LANGUAGE_NUMBER
; i
++)
64 if (LANGUAGE_LoadStringOther(i
, IDS_LANGUAGE_ID
, newlang
, sizeof(newlang
)) &&
65 !lstrcmp(lang
, newlang
))
67 LANGUAGE_SelectByNumber(i
);
72 for (i
= 0; i
<= MAX_LANGUAGE_NUMBER
; i
++)
73 if (LANGUAGE_LoadStringOther(i
, IDS_LANGUAGE_ID
, newlang
, sizeof(newlang
)))
75 LANGUAGE_SelectByNumber(i
);
79 MessageBox(Globals
.hMainWnd
, "No language found", "FATAL ERROR", MB_OK
);
83 VOID
LANGUAGE_SelectByNumber(UINT num
)
87 CHAR item
[MAX_STRING_LEN
];
90 /* Select string table */
91 Globals
.wStringTableOffset
= num
* 0x100;
94 LoadString(Globals
.hInstance
, IDS_LANGUAGE_ID
, lang
, sizeof(lang
));
95 Globals
.lpszLanguage
= lang
;
97 /* Set frame caption */
98 LANGUAGE_UpdateWindowCaption();
100 /* Change Resource names */
101 lstrcpyn(STRING_MENU_Xx
+ sizeof(STRING_MENU_Xx
) - 3, lang
, 3);
102 lstrcpyn(STRING_PAGESETUP_Xx
+ sizeof(STRING_PAGESETUP_Xx
) - 3, lang
, 3);
105 hMainMenu
= LoadMenu(Globals
.hInstance
, STRING_MENU_Xx
);
106 Globals
.hFileMenu
= GetSubMenu(hMainMenu
, 0);
107 Globals
.hEditMenu
= GetSubMenu(hMainMenu
, 1);
108 Globals
.hSearchMenu
= GetSubMenu(hMainMenu
, 2);
109 Globals
.hLanguageMenu
= GetSubMenu(hMainMenu
, 3);
110 Globals
.hHelpMenu
= GetSubMenu(hMainMenu
, 4);
112 /* Remove dummy item */
113 RemoveMenu(Globals
.hLanguageMenu
, 0, MF_BYPOSITION
);
114 /* Add language items */
115 for (i
= 0; i
<= MAX_LANGUAGE_NUMBER
; i
++)
116 if (LANGUAGE_LoadStringOther(i
, IDS_LANGUAGE_MENU_ITEM
, item
, sizeof(item
)))
117 AppendMenu(Globals
.hLanguageMenu
, MF_STRING
| MF_BYCOMMAND
,
118 NP_FIRST_LANGUAGE
+ i
, item
);
120 SetMenu(Globals
.hMainWnd
, hMainMenu
);
122 /* Destroy old menu */
123 if (Globals
.hMainMenu
) DestroyMenu(Globals
.hMainMenu
);
124 Globals
.hMainMenu
= hMainMenu
;
127 /* Update system menus */
128 for (i
= 0; Languages
[i
].name
&& lstrcmp(lang
, Languages
[i
].name
);) i
++;
129 if (Languages
[i
].name
) Options
.language
= i
;
134 VOID
LANGUAGE_DefaultHandle(WPARAM wParam
)
136 if ((wParam
>=NP_FIRST_LANGUAGE
) && (wParam
<=NP_LAST_LANGUAGE
))
137 LANGUAGE_SelectByNumber(wParam
- NP_FIRST_LANGUAGE
);
138 else printf("Unimplemented menu command %i\n", wParam
);
141 VOID
LANGUAGE_Init(VOID
)
144 Globals
.lpszLanguage
= Languages
[Options
.language
].name
;
146 CHAR buffer
[MAX_PATHNAME_LEN
], *p
;
148 PROFILE_GetWineIniString("programs", "language", "language",
149 buffer
, sizeof(buffer
));
150 Globals
.lpszLanguage
= p
= LocalLock(LocalAlloc(LMEM_FIXED
, lstrlen(buffer
)));
152 // hmemcpy(p, buffer, 1 + lstrlen(buffer));
156 /* Local Variables: */
157 /* c-file-style: "GNU" */