Hi...
I've got a small problem. When I declare an instance of the class CWindow, its both - constructor and destructor are called.
Declaration of the class:
Fuctions of CWindow:Code:class CWindow { public: CWindow(char* pType, char *pCaption, int x, int y, int cx, int cy, HMENU hId, HWND hParent); CWindow(HWND hWnd); CWindow(); ~CWindow(); friend class CMainApp; private: HWND hwnd; RECT rect; };
Use of the class:Code:CWindow::CWindow(char* pType, char* pCaption, int x, int y, int cx, int cy, HMENU hId, HWND hParent) { hwnd = CreateWindowEx(NULL, pType, pCaption, WS_CHILD|WS_VISIBLE, x, y, cx, cy, hParent, hId, hinstance, NULL); GetClientRect(hwnd, &rect); } CWindow::CWindow(HWND hWnd) { hwnd = hWnd; GetClientRect(hwnd, &rect); } CWindow::CWindow() { } CWindow::~CWindow() { DestroyWindow(hwnd); }
The debugger shows that this line is executed twice. The first execution calls the constructor, the second calls the destructor. I must be missing something very obvious here, but can't find what.Code:CWindow questionStatic = CWindow("static", pQuestion, 30, 10, 200, 30, NULL, hwnd);



LinkBack URL
About LinkBacks



