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
|
#include "globals.h"
#include "EditFieldState.h"
EditFieldState::EditFieldState(DialogState *dialog, EditField *field)
: ControlFieldState(dialog, field)
{
}
EditFieldState::~EditFieldState()
{
}
Size EditFieldState::getPreferedSize() const
{
ControlField *field = getField();
HWND hwnd = field->getHWND();
int style = GetWindowLong(hwnd, GWL_STYLE);
int exstyle = GetWindowLong(hwnd, GWL_EXSTYLE);
int format = DT_NOPREFIX | DT_EDITCONTROL;
if (!(style & ES_MULTILINE))
format |= DT_SINGLELINE;
Size ret = getTextPreferedSize(format);
RECT rc = {0};
SetRect(&rc, 0, 0, ret.x, ret.y);
AdjustWindowRectEx(&rc, style, false, exstyle);
bool hasHorScroll = field->isScrollVisible(true);
if (hasHorScroll)
rc.bottom += GetSystemMetrics(SM_CYHSCROLL);
if (field->isScrollVisible(false))
rc.right += GetSystemMetrics(SM_CXVSCROLL);
int margins = SendMessage(hwnd, EM_GETMARGINS, 0, 0);
rc.left -= LOWORD(margins);
rc.right += HIWORD(margins);
if (hasHorScroll || (style & ES_AUTOHSCROLL))
rc.right++;
ret.x = rc.right - rc.left;
ret.y = rc.bottom - rc.top;
if ((exstyle & WS_EX_CLIENTEDGE) || (exstyle & WS_EX_STATICEDGE) || (style & WS_BORDER))
{
ret.x += 3;
ret.y += 3;
}
return ret;
}
bool EditFieldState::isEmpty() const
{
return false;
}
|