Added subclassing, which finishes off newcontrol_windows.c.
This commit is contained in:
parent
816461ecbf
commit
3160b1ae1f
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue