how get child controls?

i'm doing a class for get the child controls:
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
33
34
class ChildWindows
{
private:
    vector<HWND> HwndChildWindows;
    BOOL EnumWindowsMethod( HWND hWnd )
    {
        HwndChildWindows.push_back( hWnd );
        return TRUE;
    }

    static BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam)
    {
        return reinterpret_cast <ChildWindows*> (lParam)->EnumWindowsMethod( hwnd );
    }
public:
    ChildWindows(HWND parent=ActivatedForm)
    {
        EnumChildWindows(parent, EnumChildProc, 0);
    }

    HWND& operator[](int index)
    {
        if(index>=HwndChildWindows.size())
        {
            index=HwndChildWindows.size()-1;
        }
        return HwndChildWindows[index];
    }

    int count()
    {
        return HwndChildWindows.size();
    }
};

but i'm getting a memory leak. what i'm doing wrong?
i did a mistake here:
EnumChildWindows(parent, EnumChildProc, 0);
it's:
EnumChildWindows(parent, EnumChildProc, (LPARAM)this);
thanks
Topic archived. No new replies allowed.