summaryrefslogtreecommitdiff
path: root/alf/alfspacer.cpp
blob: da18600379e242ef4b9b601c9e37f8ce7bf3de90 (plain)
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 "alfpriv.h"

TCHAR *_alf_spacerClass = NULL;

void
ALF_RegisterSpacerClass(void)
{
    WNDCLASS cls;
    ZeroMemory(&cls, sizeof(cls));

    TCHAR  classNameBuf[256];
    ALF_BuildRandomClassName(TEXT("ALFSpacer"), classNameBuf, 256);

    cls.hInstance = ALF_HINSTANCE;
    cls.hCursor = LoadCursor(NULL, (LPTSTR)IDC_ARROW);
    if (LOBYTE(LOWORD(GetVersion())) >= 4) {
        cls.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
    } else {
        // NT 3.x has white dialog backgrounds
        cls.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
    }
    cls.lpszClassName = classNameBuf;
    cls.cbWndExtra = sizeof(void*);
    cls.lpfnWndProc = DefWindowProc;

    ATOM classatom = RegisterClass(&cls);
    if (!classatom)
        MessageBox(NULL, TEXT("FATAL: Could not register spacer class"), NULL, MB_OK);

    _alf_spacerClass = MAKEINTATOM(classatom);
}

HWND
ALF_AddSpacer(HWND parent, WORD id, UINT x, UINT y, UINT cptWidth, UINT cptHeight, DWORD layoutFlags)
{
    HWND hwndSpacer = CreateWindowEx(0,
                                     _alf_spacerClass,
                                     TEXT(""),
                                     WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN,
                                     0, 0, 0, 0,
                                     parent,
                                     (HMENU)(int)id,
                                     ALF_HINSTANCE,
                                     NULL);

    ALFWidgetLayoutParams p;
    ZeroMemory(&p, sizeof(p));
    p.hwnd = hwndSpacer;
    p.x = x;
    p.y = y;
    p.width = cptWidth;
    p.height = cptHeight;
    p.flags = layoutFlags;

    ALF_AddWidgetEx(parent, &p);

    return hwndSpacer;
}