1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
#include <windows.h>
#include "input.h"
#include "defs.h"
#include "nsis.h"
#include "rtl.h"
extern struct nsDialog g_dialog;
static int NSDFUNC ConvertPlacement(char *str, int total, int height)
{
char unit = *CharPrev(str, str + lstrlen(str));
int x = myatoi(str);
if (unit == '%')
{
if (x < 0)
{
return MulDiv(total, 100 + x, 100);
}
return MulDiv(total, x, 100);
}
else if (unit == 'u')
{
RECT r;
r.left = r.top = x;
MapDialogRect(g_dialog.hwParent, &r);
if (height)
return x >= 0 ? r.top : total + r.top;
else
return x >= 0 ? r.left : total + r.left;
}
if (x < 0)
{
return total + x;
}
return x;
}
int NSDFUNC PopPlacement(int *x, int *y, int *width, int *height)
{
RECT dialogRect;
int dialogWidth;
int dialogHeight;
char buf[1024];
GetClientRect(g_dialog.hwDialog, &dialogRect);
dialogWidth = dialogRect.right;
dialogHeight = dialogRect.bottom;
if (popstring(buf, 1024))
return 1;
*x = ConvertPlacement(buf, dialogWidth, 0);
if (popstring(buf, 1024))
return 1;
*y = ConvertPlacement(buf, dialogHeight, 1);
if (popstring(buf, 1024))
return 1;
*width = ConvertPlacement(buf, dialogWidth, 0);
if (popstring(buf, 1024))
return 1;
*height = ConvertPlacement(buf, dialogHeight, 1);
ConvertPosToRTL(x, *width, dialogWidth);
return 0;
}
|