Destroying child window (Edit control)

Hi there.

I've got a basic winapi app that I'm writing. I have a class, which contains an array of other classes. Since the code is quite long, and I suspect that I'm just doign it wrong, I'll just post some similar code - if I need to post the real thing, I can.

My problem is that when I call DestroyWindow, the control remains on the screen. I've invalidated the entire parent window, I've invalidated the control. I've even tried to hide the control, without luck. I can confirm that the HWND EditBox does become a NULL value after calling DestroyWindow.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
class B;

class A{
public:
A();
~A();
void SomeFunction(){
for (int i=0;i<10;i++)
var[i]=B(i);
};

private:
B var[25];
}

class B{
public:
B(int i){
CreateWindows(i);
};
~B();
CreateWinows(int line){
EditBox=CreateWindowEx(NULL,"Edit",WS_CHILD|WS_VISIBLE|WS_OVERLAPPED,10,10*line,45,24,hwnd,NULL,ghInstance,NULL);}

void DestroyWindows(){
DestroyWindow(EditBox);
InvalidateRect(hwnd,NULL,true);
}

private:
HWND EditBox;
}


code follows this execution:
1) Create 'A'.
2) user interaction calls A.SomeFunction()
3) User interaction causes A.vars[somewhere].DestroyWindows() to be called

I know that I'm hitting the DestroyWindows function, as it will hit breakpoints, as well as do other cleanup within that function. It just won't make the child controls, whether Edit, Combobox, or Button, disappear.
Last edited on by admin
Topic archived. No new replies allowed.