From 6185187506dd4bebaa801aaa1d4d1c783557e786 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Tue, 14 Apr 2015 10:20:07 -0400 Subject: More uiParent work. Something I did broke stack removal... --- new/newcontrol_windows.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'new/newcontrol_windows.c') diff --git a/new/newcontrol_windows.c b/new/newcontrol_windows.c index 12a26f3..105b70c 100644 --- a/new/newcontrol_windows.c +++ b/new/newcontrol_windows.c @@ -32,25 +32,22 @@ static uintptr_t singleHandle(uiControl *c) } static void singleSetParent(uiControl *c, uiParent *parent) -{ - singleHWND *s = (singleHWND *) (c->internal); - - s->parent = parent; - if (SetParent(s->hwnd, uiParentHWND(s->parent)) == NULL) - logLastError("error setting control parent in singleSetParent()"); - uiParentUpdate(s->parent); -} - -static void singleRemoveParent(uiControl *c) { singleHWND *s = (singleHWND *) (c->internal); uiParent *oldparent; + HWND newParentHWND; oldparent = s->parent; - s->parent = NULL; - if (SetParent(s->hwnd, initialParent) == NULL) - logLastError("error removing control parent in singleSetParent()"); - uiParentUpdate(oldparent); + s->parent = parent; + newParentHWND = initialParent; + if (s->parent != NULL) + newParentHWND = uiParentHWND(s->parent); + if (SetParent(s->hwnd, newParentHWND) == NULL) + logLastError("error setting control parent in singleSetParent()"); + if (oldparent != NULL) + uiParentUpdate(oldparent); + if (s->parent != NULL) + uiParentUpdate(s->parent); } static void singleResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height, uiSizing *d) @@ -199,7 +196,6 @@ uiControl *uiWindowsNewControl(uiWindowsNewControlParams *p) c->destroy = singleDestroy; c->handle = singleHandle; c->setParent = singleSetParent; - c->removeParent = singleRemoveParent; c->resize = singleResize; c->visible = singleVisible; c->show = singleShow; -- cgit v1.2.3