updated parameter use to new exdll
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1120 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
ceaf3dfead
commit
6525b27baa
2 changed files with 45 additions and 89 deletions
|
@ -1,54 +1,25 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
|
||||||
typedef struct _stack_t {
|
// JF> updated usage
|
||||||
struct _stack_t *next;
|
// call like this:
|
||||||
char text[1]; // this should be the length of string_size
|
// LangDLL:LangDialog "Window Title" "Window subtext" <number of languages>[F] language_text language_id ... [font_size font_face]
|
||||||
} stack_t;
|
// 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
|
||||||
|
|
||||||
int popstring(char *str); // 0 on success, 1 on empty stack
|
|
||||||
void pushstring(char *str);
|
|
||||||
|
|
||||||
enum
|
#include "../exdll/exdll.h"
|
||||||
{
|
|
||||||
INST_0, // $0
|
|
||||||
INST_1, // $1
|
|
||||||
INST_2, // $2
|
|
||||||
INST_3, // $3
|
|
||||||
INST_4, // $4
|
|
||||||
INST_5, // $5
|
|
||||||
INST_6, // $6
|
|
||||||
INST_7, // $7
|
|
||||||
INST_8, // $8
|
|
||||||
INST_9, // $9
|
|
||||||
INST_R0, // $R0
|
|
||||||
INST_R1, // $R1
|
|
||||||
INST_R2, // $R2
|
|
||||||
INST_R3, // $R3
|
|
||||||
INST_R4, // $R4
|
|
||||||
INST_R5, // $R5
|
|
||||||
INST_R6, // $R6
|
|
||||||
INST_R7, // $R7
|
|
||||||
INST_R8, // $R8
|
|
||||||
INST_R9, // $R9
|
|
||||||
INST_CMDLINE, // $CMDLINE
|
|
||||||
INST_INSTDIR, // $INSTDIR
|
|
||||||
INST_OUTDIR, // $OUTDIR
|
|
||||||
INST_EXEDIR, // $EXEDIR
|
|
||||||
INST_LANG, // $LANGUAGE
|
|
||||||
__INST_LAST
|
|
||||||
};
|
|
||||||
|
|
||||||
char *getuservariable(int varnum);
|
|
||||||
int myatoi(char *s);
|
int myatoi(char *s);
|
||||||
|
|
||||||
HINSTANCE g_hInstance;
|
HINSTANCE g_hInstance;
|
||||||
HWND g_hwndParent;
|
HWND g_hwndParent;
|
||||||
int g_stringsize;
|
|
||||||
stack_t **g_stacktop;
|
|
||||||
char *g_variables;
|
|
||||||
|
|
||||||
char temp[1024];
|
char temp[1024];
|
||||||
|
char g_wndtitle[1024], g_wndtext[1024];
|
||||||
|
int dofont;
|
||||||
|
|
||||||
int langs_num;
|
int langs_num;
|
||||||
|
|
||||||
|
@ -66,10 +37,8 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
for (i = langs_num - 1; i >= 0; i--) {
|
for (i = langs_num - 1; i >= 0; i--) {
|
||||||
SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_ADDSTRING, 0, (LPARAM)langs[i].name);
|
SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_ADDSTRING, 0, (LPARAM)langs[i].name);
|
||||||
}
|
}
|
||||||
if (!popstring(temp))
|
SetDlgItemText(hwndDlg, IDC_TEXT, g_wndtext);
|
||||||
SetDlgItemText(hwndDlg, IDC_TEXT, temp);
|
SetWindowText(hwndDlg, g_wndtitle);
|
||||||
if (!popstring(temp))
|
|
||||||
SetWindowText(hwndDlg, temp);
|
|
||||||
SendDlgItemMessage(hwndDlg, IDC_APPICON, STM_SETICON, (LPARAM)LoadIcon(GetModuleHandle(0),MAKEINTRESOURCE(103)), 0);
|
SendDlgItemMessage(hwndDlg, IDC_APPICON, STM_SETICON, (LPARAM)LoadIcon(GetModuleHandle(0),MAKEINTRESOURCE(103)), 0);
|
||||||
for (i = 0; i < langs_num; i++) {
|
for (i = 0; i < langs_num; i++) {
|
||||||
if (!lstrcmp(langs[i].id, getuservariable(INST_LANG))) {
|
if (!lstrcmp(langs[i].id, getuservariable(INST_LANG))) {
|
||||||
|
@ -77,7 +46,8 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!popstring(temp))
|
if (dofont && !popstring(temp))
|
||||||
|
{
|
||||||
size = myatoi(temp);
|
size = myatoi(temp);
|
||||||
if (!popstring(temp)) {
|
if (!popstring(temp)) {
|
||||||
LOGFONT f = {0,};
|
LOGFONT f = {0,};
|
||||||
|
@ -90,6 +60,7 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, WM_SETFONT, (WPARAM)font, 1);
|
SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, WM_SETFONT, (WPARAM)font, 1);
|
||||||
SendDlgItemMessage(hwndDlg, IDC_TEXT, WM_SETFONT, (WPARAM)font, 1);
|
SendDlgItemMessage(hwndDlg, IDC_TEXT, WM_SETFONT, (WPARAM)font, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ShowWindow(hwndDlg, SW_SHOW);
|
ShowWindow(hwndDlg, SW_SHOW);
|
||||||
break;
|
break;
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
|
@ -119,24 +90,33 @@ void __declspec(dllexport) LangDialog(HWND hwndParent, int string_size,
|
||||||
char *variables, stack_t **stacktop)
|
char *variables, stack_t **stacktop)
|
||||||
{
|
{
|
||||||
g_hwndParent=hwndParent;
|
g_hwndParent=hwndParent;
|
||||||
g_stringsize=string_size;
|
EXDLL_INIT();
|
||||||
g_stacktop=stacktop;
|
|
||||||
g_variables=variables;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
popstring(temp);
|
|
||||||
|
if (popstring(g_wndtitle)) return;
|
||||||
|
if (popstring(g_wndtext)) return;
|
||||||
|
|
||||||
|
if (popstring(temp)) return;
|
||||||
langs_num = myatoi(temp);
|
langs_num = myatoi(temp);
|
||||||
|
{
|
||||||
|
char *p=temp;
|
||||||
|
while (*p) if (*p++ == 'F') dofont=1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!langs_num) return;
|
||||||
|
|
||||||
langs = (struct lang *)GlobalAlloc(GPTR, langs_num*sizeof(struct lang));
|
langs = (struct lang *)GlobalAlloc(GPTR, langs_num*sizeof(struct lang));
|
||||||
|
|
||||||
for (i = 0; i < langs_num; i++) {
|
for (i = 0; i < langs_num; i++) {
|
||||||
if (popstring(temp)) return;
|
|
||||||
langs[i].id = GlobalAlloc(GPTR, lstrlen(temp)+1);
|
|
||||||
lstrcpy(langs[i].id, temp);
|
|
||||||
if (popstring(temp)) return;
|
if (popstring(temp)) return;
|
||||||
langs[i].name = GlobalAlloc(GPTR, lstrlen(temp)+1);
|
langs[i].name = GlobalAlloc(GPTR, lstrlen(temp)+1);
|
||||||
lstrcpy(langs[i].name, temp);
|
lstrcpy(langs[i].name, temp);
|
||||||
|
|
||||||
|
if (popstring(temp)) return;
|
||||||
|
langs[i].id = GlobalAlloc(GPTR, lstrlen(temp)+1);
|
||||||
|
lstrcpy(langs[i].id, temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_DIALOG), 0, DialogProc);
|
DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_DIALOG), 0, DialogProc);
|
||||||
|
@ -149,34 +129,6 @@ BOOL WINAPI _DllMainCRTStartup(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lp
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// utility functions (not required but often useful)
|
|
||||||
int popstring(char *str)
|
|
||||||
{
|
|
||||||
stack_t *th;
|
|
||||||
if (!g_stacktop || !*g_stacktop) return 1;
|
|
||||||
th=(*g_stacktop);
|
|
||||||
lstrcpy(str,th->text);
|
|
||||||
*g_stacktop = th->next;
|
|
||||||
GlobalFree((HGLOBAL)th);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void pushstring(char *str)
|
|
||||||
{
|
|
||||||
stack_t *th;
|
|
||||||
if (!g_stacktop) return;
|
|
||||||
th=(stack_t*)GlobalAlloc(GPTR,sizeof(stack_t)+g_stringsize);
|
|
||||||
lstrcpyn(th->text,str,g_stringsize);
|
|
||||||
th->next=*g_stacktop;
|
|
||||||
*g_stacktop=th;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *getuservariable(int varnum)
|
|
||||||
{
|
|
||||||
if (varnum < 0 || varnum >= __INST_LAST) return NULL;
|
|
||||||
return g_variables+varnum*g_stringsize;
|
|
||||||
}
|
|
||||||
|
|
||||||
int myatoi(char *s)
|
int myatoi(char *s)
|
||||||
{
|
{
|
||||||
unsigned int v=0;
|
unsigned int v=0;
|
||||||
|
|
|
@ -100,6 +100,10 @@ SOURCE=.\LangDLL.c
|
||||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\ExDLL\exdll.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\resource.h
|
SOURCE=.\resource.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# End Group
|
# End Group
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue