diff options
Diffstat (limited to 'alf/alfcontrol.cpp')
| -rw-r--r-- | alf/alfcontrol.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/alf/alfcontrol.cpp b/alf/alfcontrol.cpp new file mode 100644 index 0000000..a630fa7 --- /dev/null +++ b/alf/alfcontrol.cpp @@ -0,0 +1,53 @@ +#include "alfpriv.h" + + +TCHAR _alf_controlClass[28] = {0}; + +static LRESULT CALLBACK +ALF_Control_InitialWindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) +{ + if (msg == WM_NCCREATE) { + ALFControlCreateParams *params = (ALFControlCreateParams *)((CREATESTRUCT *)lparam)->lpCreateParams; + SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)params->windowProc); + return params->windowProc(hwnd, msg, wparam, lparam); + } + + return DefWindowProc(hwnd, msg, wparam, lparam); +} + +void +ALF_RegisterControlClass(void) +{ + WNDCLASS cls; + ZeroMemory(&cls, sizeof(cls)); + + ALF_BuildUniqueName(_alf_controlClass, TEXT("ALFControl."), (ULONG_PTR)&_alf_controlClass[0]); + + cls.style = CS_DBLCLKS; + cls.hInstance = ALF_HINSTANCE; + cls.hCursor = LoadCursor(NULL, (LPTSTR)IDC_ARROW); + cls.lpszClassName = _alf_controlClass; + cls.cbWndExtra = sizeof(void*); + cls.lpfnWndProc = ALF_Control_InitialWindowProc; + + ATOM classatom = RegisterClass(&cls); + if (!classatom) + MessageBox(NULL, TEXT("FATAL: Could not register control class"), NULL, MB_OK); +} + +HWND +ALF_CreateControlWindow(DWORD exstyle, const TCHAR *text, DWORD style, + int x, int y, int w, int h, HWND parent, HMENU hmenu, + WNDPROC windowProc, void *param) +{ + ALFControlCreateParams p = { windowProc, param }; + return CreateWindowEx(exstyle, + _alf_controlClass, + text, + style, + x, y, w, h, + parent, + hmenu, + ALF_HINSTANCE, + &p); +} |
