summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--new/newcontrol_windows.c27
-rw-r--r--new/ui_windows.h2
2 files changed, 26 insertions, 3 deletions
diff --git a/new/newcontrol_windows.c b/new/newcontrol_windows.c
index 64d59a3..61f802a 100644
--- a/new/newcontrol_windows.c
+++ b/new/newcontrol_windows.c
@@ -51,6 +51,28 @@ static void singleContainerHide(uiControl *c)
ShowWindow(S(c)->hwnd, SW_HIDE);
}
+static LRESULT CALLBACK singleSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
+{
+ uiSingleHWNDControl *c = (uiSingleHWNDControl *) dwRefData;
+ LRESULT lResult;
+
+ switch (uMsg) {
+ case msgCOMMAND:
+ if ((*(c->onWM_COMMAND))((uiControl *) c, wParam, lParam, c->onCommandNotifyData, &lResult) != FALSE)
+ return lResult;
+ break;
+ case msgNOTIFY:
+ if ((*(c->onWM_NOTIFY))((uiControl *) c, wParam, lParam, c->onCommandNotifyData, &lResult) != FALSE)
+ return lResult;
+ break;
+ case WM_NCDESTROY:
+ if ((*fv_RemoveWindowSubclass)(hwnd, singleSubclassProc, uIdSubclass) == FALSE)
+ logLastError("error removing Windows control subclass in singleSubclassProc()");
+ break;
+ }
+ return (*fv_DefSubclassProc)(hwnd, uMsg, wParam, lParam);
+}
+
uiControl *uiWindowsNewControl(uiWindowsNewControlParams *p)
{
uiSingleHWNDControl *c;
@@ -64,7 +86,7 @@ uiControl *uiWindowsNewControl(uiWindowsNewControlParams *p)
// TODO specify control IDs properly
initialParent, NULL, p->hInstance, NULL);
if (c->hwnd == NULL)
- logLastError("error creating control in newSingleHWNDControl()");
+ logLastError("error creating control in uiWindowsNewControl()");
c->control.handle = singleHandle;
c->control.setParent = singleSetParent;
@@ -78,7 +100,8 @@ uiControl *uiWindowsNewControl(uiWindowsNewControlParams *p)
c->onCommandNotifyData = p->onCommandNotifyData;
c->preferredSize = p->preferredSize;
- // TODO subclass
+ if ((*fv_SetWindowSubclass)(c->hwnd, singleSubclassProc, 0, c) == FALSE)
+ logLastError("error subclassing Windows control in uiWindowsNewControl()");
return (uiControl *) c;
}
diff --git a/new/ui_windows.h b/new/ui_windows.h
index c2a21b4..330b7cb 100644
--- a/new/ui_windows.h
+++ b/new/ui_windows.h
@@ -19,7 +19,7 @@ struct uiWindowsNewControlParams {
// These are called when the control sends a WM_COMMAND or WM_NOTIFY (respectively) to its parent.
// ui redirects the message back and calls these functions.
- // Store the result in *lResult and return TRUE to return the given result; return FALSE to pass the notification up to your window procedure.
+ // Store the result in *lResult and return any non-FALSE value (such as TRUE) to return the given result; return FALSE to pass the notification up to your window procedure.
// Note that these are only issued if they come from the uiControl itself; notifications from children of the uiControl (such as a header control) will be received normally.
BOOL (*onWM_COMMAND)(uiControl *c, WPARAM wParam, LPARAM lParam, void *data, LRESULT *lResult);
BOOL (*onWM_NOTIFY)(uiControl *c, WPARAM wParam, LPARAM lParam, void *data, LRESULT *lResult);