2002-08-28 22:21:37 +00:00
|
|
|
#include <windows.h>
|
|
|
|
#include "resource.h"
|
|
|
|
|
2002-09-21 18:45:38 +00:00
|
|
|
// JF> updated usage
|
|
|
|
// call like this:
|
|
|
|
// LangDLL:LangDialog "Window Title" "Window subtext" <number of languages>[F] language_text language_id ... [font_size font_face]
|
|
|
|
// ex:
|
|
|
|
// LangDLL:LangDialog "Language Selection" "Choose a language" 2 French 1036 English 1033
|
|
|
|
// or (the F after the 2 means we're supplying font information)
|
|
|
|
// LangDLL:LangDialog "Language Selection" "Choose a language" 2F French 1036 English 1033 12 Garamond
|
2002-08-28 22:21:37 +00:00
|
|
|
|
|
|
|
|
2005-03-17 21:26:59 +00:00
|
|
|
#include "../ExDLL/exdll.h"
|
2002-09-21 18:45:38 +00:00
|
|
|
|
2002-08-28 22:21:37 +00:00
|
|
|
int myatoi(char *s);
|
|
|
|
|
|
|
|
HINSTANCE g_hInstance;
|
|
|
|
HWND g_hwndParent;
|
|
|
|
|
|
|
|
char temp[1024];
|
2002-09-21 18:45:38 +00:00
|
|
|
char g_wndtitle[1024], g_wndtext[1024];
|
|
|
|
int dofont;
|
2002-08-28 22:21:37 +00:00
|
|
|
|
|
|
|
int langs_num;
|
|
|
|
|
|
|
|
struct lang {
|
|
|
|
char *name;
|
|
|
|
char *id;
|
|
|
|
} *langs;
|
|
|
|
|
|
|
|
BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2002-08-29 10:48:08 +00:00
|
|
|
int i, size;
|
|
|
|
static HFONT font;
|
2002-08-28 22:21:37 +00:00
|
|
|
switch (uMsg) {
|
|
|
|
case WM_INITDIALOG:
|
2002-08-28 22:38:14 +00:00
|
|
|
for (i = langs_num - 1; i >= 0; i--) {
|
2002-08-28 22:21:37 +00:00
|
|
|
SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_ADDSTRING, 0, (LPARAM)langs[i].name);
|
2002-08-28 22:38:14 +00:00
|
|
|
}
|
2002-09-21 18:45:38 +00:00
|
|
|
SetDlgItemText(hwndDlg, IDC_TEXT, g_wndtext);
|
|
|
|
SetWindowText(hwndDlg, g_wndtitle);
|
2002-08-28 22:38:14 +00:00
|
|
|
SendDlgItemMessage(hwndDlg, IDC_APPICON, STM_SETICON, (LPARAM)LoadIcon(GetModuleHandle(0),MAKEINTRESOURCE(103)), 0);
|
|
|
|
for (i = 0; i < langs_num; i++) {
|
|
|
|
if (!lstrcmp(langs[i].id, getuservariable(INST_LANG))) {
|
2002-08-28 22:44:57 +00:00
|
|
|
SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_SETCURSEL, langs_num-i-1, 0);
|
2002-08-28 22:38:14 +00:00
|
|
|
break;
|
|
|
|
}
|
2002-08-28 22:21:37 +00:00
|
|
|
}
|
2002-09-21 18:45:38 +00:00
|
|
|
if (dofont && !popstring(temp))
|
|
|
|
{
|
2002-08-29 10:48:08 +00:00
|
|
|
size = myatoi(temp);
|
2002-09-21 18:45:38 +00:00
|
|
|
if (!popstring(temp)) {
|
|
|
|
LOGFONT f = {0,};
|
2003-03-10 21:13:18 +00:00
|
|
|
if (lstrcmp(temp, "MS Shell Dlg")) {
|
|
|
|
f.lfHeight = -MulDiv(size, GetDeviceCaps(GetDC(hwndDlg), LOGPIXELSY), 72);
|
|
|
|
lstrcpy(f.lfFaceName, temp);
|
|
|
|
font = CreateFontIndirect(&f);
|
|
|
|
SendMessage(hwndDlg, WM_SETFONT, (WPARAM)font, 1);
|
|
|
|
SendDlgItemMessage(hwndDlg, IDOK, WM_SETFONT, (WPARAM)font, 1);
|
|
|
|
SendDlgItemMessage(hwndDlg, IDCANCEL, WM_SETFONT, (WPARAM)font, 1);
|
|
|
|
SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, WM_SETFONT, (WPARAM)font, 1);
|
|
|
|
SendDlgItemMessage(hwndDlg, IDC_TEXT, WM_SETFONT, (WPARAM)font, 1);
|
|
|
|
}
|
2002-09-21 18:45:38 +00:00
|
|
|
}
|
2002-08-29 10:48:08 +00:00
|
|
|
}
|
2002-08-28 22:21:37 +00:00
|
|
|
ShowWindow(hwndDlg, SW_SHOW);
|
|
|
|
break;
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD(wParam)) {
|
|
|
|
case IDOK:
|
2002-08-28 22:47:25 +00:00
|
|
|
pushstring(langs[langs_num-SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETCURSEL, 0, 0)-1].id);
|
2002-08-28 22:21:37 +00:00
|
|
|
EndDialog(hwndDlg, 0);
|
|
|
|
break;
|
|
|
|
case IDCANCEL:
|
|
|
|
pushstring("cancel");
|
|
|
|
EndDialog(hwndDlg, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_CLOSE:
|
2002-08-29 10:48:08 +00:00
|
|
|
if (font) DeleteObject(font);
|
2002-08-28 22:21:37 +00:00
|
|
|
pushstring("cancel");
|
|
|
|
EndDialog(hwndDlg, 1);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void __declspec(dllexport) LangDialog(HWND hwndParent, int string_size,
|
|
|
|
char *variables, stack_t **stacktop)
|
|
|
|
{
|
|
|
|
g_hwndParent=hwndParent;
|
2002-09-21 18:45:38 +00:00
|
|
|
EXDLL_INIT();
|
2002-08-28 22:21:37 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
int i;
|
2003-03-09 21:24:04 +00:00
|
|
|
BOOL bPopOneMore = FALSE;
|
2002-09-21 18:45:38 +00:00
|
|
|
|
|
|
|
if (popstring(g_wndtitle)) return;
|
|
|
|
if (popstring(g_wndtext)) return;
|
|
|
|
|
|
|
|
if (popstring(temp)) return;
|
2003-03-09 20:17:27 +00:00
|
|
|
if (*temp == 'A')
|
|
|
|
{
|
|
|
|
stack_t *th;
|
|
|
|
langs_num=0;
|
|
|
|
th=(*g_stacktop);
|
|
|
|
while (th && th->text[0]) {
|
|
|
|
langs_num++;
|
|
|
|
th = th->next;
|
|
|
|
}
|
|
|
|
if (!th) return;
|
|
|
|
langs_num /= 2;
|
2003-03-09 21:24:04 +00:00
|
|
|
bPopOneMore = TRUE;
|
2003-03-09 20:17:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
langs_num = myatoi(temp);
|
2002-09-21 18:45:38 +00:00
|
|
|
{
|
|
|
|
char *p=temp;
|
|
|
|
while (*p) if (*p++ == 'F') dofont=1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!langs_num) return;
|
2002-08-28 22:21:37 +00:00
|
|
|
|
|
|
|
langs = (struct lang *)GlobalAlloc(GPTR, langs_num*sizeof(struct lang));
|
|
|
|
|
|
|
|
for (i = 0; i < langs_num; i++) {
|
|
|
|
if (popstring(temp)) return;
|
|
|
|
langs[i].name = GlobalAlloc(GPTR, lstrlen(temp)+1);
|
|
|
|
lstrcpy(langs[i].name, temp);
|
2002-09-21 18:45:38 +00:00
|
|
|
|
|
|
|
if (popstring(temp)) return;
|
|
|
|
langs[i].id = GlobalAlloc(GPTR, lstrlen(temp)+1);
|
|
|
|
lstrcpy(langs[i].id, temp);
|
2002-08-28 22:21:37 +00:00
|
|
|
}
|
2003-03-09 21:24:04 +00:00
|
|
|
if (bPopOneMore) {
|
|
|
|
if (popstring(temp)) return;
|
|
|
|
}
|
2002-08-28 22:21:37 +00:00
|
|
|
|
|
|
|
DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_DIALOG), 0, DialogProc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-12 20:24:53 +00:00
|
|
|
BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
|
2002-08-28 22:21:37 +00:00
|
|
|
{
|
|
|
|
g_hInstance=hInst;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int myatoi(char *s)
|
|
|
|
{
|
|
|
|
unsigned int v=0;
|
2003-03-09 20:17:27 +00:00
|
|
|
for (;;)
|
2002-08-28 22:21:37 +00:00
|
|
|
{
|
2003-03-09 20:17:27 +00:00
|
|
|
int c=*s++ - '0';
|
|
|
|
if (c < 0 || c > 9) break;
|
|
|
|
v*=10;
|
|
|
|
v+=c;
|
2002-08-28 22:21:37 +00:00
|
|
|
}
|
|
|
|
return (int)v;
|
2005-03-17 21:26:59 +00:00
|
|
|
}
|