From 92b43720b6b33e838f8e9b5dffaa556529de3d52 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Thu, 9 Apr 2015 16:21:09 -0400 Subject: Decided to split control removal from parent into its own method removeParent() rather than automatically doing it in setParent(). --- new/newcontrol_windows.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'new/newcontrol_windows.c') diff --git a/new/newcontrol_windows.c b/new/newcontrol_windows.c index 56719b3..1ff404b 100644 --- a/new/newcontrol_windows.c +++ b/new/newcontrol_windows.c @@ -32,16 +32,25 @@ static uintptr_t singleHandle(uiControl *c) static void singleSetParent(uiControl *c, uintptr_t parent) { uiSingleHWNDControl *s = S(c); - uintptr_t oldparent; - oldparent = s->parent; s->parent = parent; if (SetParent(s->hwnd, (HWND) (s->parent)) == NULL) - logLastError("error changing control parent in singleSetParent()"); - updateParent(oldparent); + logLastError("error setting control parent in singleSetParent()"); updateParent(s->parent); } +static void singleRemoveParent(uiControl *c) +{ + uiSingleHWNDControl *s = S(c); + uintptr_t oldparent; + + oldparent = s->parent; + s->parent = 0; + if (SetParent(s->hwnd, initialParent) == NULL) + logLastError("error removing control parent in singleSetParent()"); + updateParent(oldparent); +} + static uiSize singlePreferredSize(uiControl *c, uiSizing *d) { uiSize size; @@ -102,6 +111,7 @@ uiControl *uiWindowsNewControl(uiWindowsNewControlParams *p) c->control.destroy = singleDestroy; c->control.handle = singleHandle; c->control.setParent = singleSetParent; + c->control.removeParent = singleRemoveParent; c->control.preferredSize = singlePreferredSize; c->control.resize = singleResize; -- cgit v1.2.3