summaryrefslogtreecommitdiff
path: root/alf/alflabel.cpp
diff options
context:
space:
mode:
authorJonas Kümmerlin <jonas@kuemmerlin.eu>2020-05-29 23:43:00 +0200
committerJonas Kümmerlin <jonas@kuemmerlin.eu>2020-05-29 23:43:00 +0200
commitc9ebff8e7de093e7705aab6208593fae048ad98d (patch)
tree06f641c182e4013e95c7fa1f255e4adbd32a67f2 /alf/alflabel.cpp
parent46326d57e0c912f265595ffed375d211bbe23f44 (diff)
controls: subclass generic "ALFControl" window
The idea is that the compiler can strip unused controls when linking statically, but the window class initialization functions blocked that.
Diffstat (limited to 'alf/alflabel.cpp')
-rw-r--r--alf/alflabel.cpp41
1 files changed, 8 insertions, 33 deletions
diff --git a/alf/alflabel.cpp b/alf/alflabel.cpp
index d0b9b59..e7e2ee3 100644
--- a/alf/alflabel.cpp
+++ b/alf/alflabel.cpp
@@ -10,8 +10,6 @@ typedef struct {
int dpi;
} ALFLabelPriv;
-TCHAR *_alf_labelClass;
-
static int
ALF__LabelTopPadding(HWND hwnd, ALFLabelPriv *priv)
{
@@ -328,14 +326,14 @@ ALF__LabelWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
HWND
ALF_AddLabel(HWND win, WORD id, int x, int y, const TCHAR *text)
{
- HWND hwndLabel = CreateWindow(_alf_labelClass,
- text,
- WS_CHILD | WS_VISIBLE,
- 0, 0, 100, 100,
- win,
- (HMENU)(ULONG_PTR)id,
- ALF_HINSTANCE,
- NULL);
+ HWND hwndLabel = ALF_CreateControlWindow(0,
+ text,
+ WS_CHILD | WS_VISIBLE,
+ 0, 0, 100, 100,
+ win,
+ (HMENU)(ULONG_PTR)id,
+ ALF__LabelWindowProc,
+ NULL);
ALFLabelPriv *priv = ALF_New(ALFLabelPriv, 1);
priv->style = ALF_LABEL_ALIGN_LEFT | ALF_LABEL_ALIGN_TOP_LIKE_EDIT;
@@ -349,29 +347,6 @@ ALF_AddLabel(HWND win, WORD id, int x, int y, const TCHAR *text)
return hwndLabel;
}
-
-void
-ALF_RegisterLabelClass(void)
-{
- WNDCLASS cls;
- ZeroMemory(&cls, sizeof(cls));
-
- TCHAR classNameBuf[256];
- ALF_BuildUniqueName(classNameBuf, TEXT("ALFLabel."), (ULONG_PTR)&_alf_labelClass);
-
- cls.hInstance = ALF_HINSTANCE;
- cls.hCursor = LoadCursor(NULL, (LPTSTR)IDC_ARROW);
- cls.lpszClassName = classNameBuf;
- cls.cbWndExtra = sizeof(void*);
- cls.lpfnWndProc = ALF__LabelWindowProc;
-
- ATOM classatom = RegisterClass(&cls);
- if (!classatom)
- MessageBox(NULL, TEXT("FATAL: Could not register label class"), NULL, MB_OK);
-
- _alf_labelClass = MAKEINTATOM(classatom);
-}
-
DWORD
ALF_LabelStyle(HWND hwndLabel)
{