From c9ebff8e7de093e7705aab6208593fae048ad98d Mon Sep 17 00:00:00 2001 From: Jonas Kümmerlin Date: Fri, 29 May 2020 23:43:00 +0200 Subject: 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. --- alf/alfgroupbox.cpp | 41 ++++++++--------------------------------- 1 file changed, 8 insertions(+), 33 deletions(-) (limited to 'alf/alfgroupbox.cpp') diff --git a/alf/alfgroupbox.cpp b/alf/alfgroupbox.cpp index 5c459dc..bfe5519 100644 --- a/alf/alfgroupbox.cpp +++ b/alf/alfgroupbox.cpp @@ -5,8 +5,6 @@ #define GBS_DISABLED 2 #define TMT_TEXTCOLOR 3803 -TCHAR *_alf_groupboxClass = NULL; - typedef struct { ALFLayout layout; HTHEME theme; @@ -342,40 +340,17 @@ ALF_GroupBox_WindowProc(HWND window, UINT msg, WPARAM wparam, LPARAM lparam) return DefWindowProc(window, msg, wparam, lparam); } -void -ALF_RegisterGroupBoxClass(void) -{ - WNDCLASS cls; - ZeroMemory(&cls, sizeof(cls)); - - TCHAR classNameBuf[256]; - ALF_BuildUniqueName(classNameBuf, TEXT("ALFGroupBox."), (ULONG_PTR)&_alf_groupboxClass); - - cls.hInstance = ALF_HINSTANCE; - cls.hCursor = LoadCursor(NULL, (LPTSTR)IDC_ARROW); - cls.lpszClassName = classNameBuf; - cls.cbWndExtra = sizeof(void*); - cls.lpfnWndProc = ALF_GroupBox_WindowProc; - - ATOM classatom = RegisterClass(&cls); - if (!classatom) - MessageBox(NULL, TEXT("FATAL: Could not register groupbox class"), NULL, MB_OK); - - _alf_groupboxClass = MAKEINTATOM(classatom); -} - HWND ALF_AddGroupBox(HWND parent, WORD id, int x, int y, const TCHAR *text) { - HWND hwndPanel = CreateWindowEx(WS_EX_CONTROLPARENT, - _alf_groupboxClass, - text, - WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_TABSTOP, - 0, 0, 0, 0, - parent, - (HMENU)(UINT_PTR)id, - ALF_HINSTANCE, - NULL); + HWND hwndPanel = ALF_CreateControlWindow(WS_EX_CONTROLPARENT, + text, + WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_TABSTOP, + 0, 0, 0, 0, + parent, + (HMENU)(UINT_PTR)id, + ALF_GroupBox_WindowProc, + NULL); ALF_AddWidget(parent, x, y, hwndPanel, 0, 0, ALF_LAYOUT_SIZE_QUERY | ALF_LAYOUT_INHERITFONT | ALF_LAYOUT_INHERITBGCOLOR | ALF_LAYOUT_SENDBGCHANGE | ALF_LAYOUT_SENDDPICHANGE); -- cgit v1.2.3