Ventanas que cierran solas (fernando leelo, por fa
Publicado por Nelek (816 intervenciones) el 12/07/2006 13:14:40
Hola,
resulta que estoy intentando crear ventanas adicionales en mi proyecto ya resulta que las crea, pero que las cierra automaticamente sin casi dar tiempo a verlas. Yo veo la ventana gracias a un AfxMessageBox que le pongo pa detener el sistema, si no... nada.
Lo que he hecho es lo siguiente:
//Fichero cabecera de la ventana que quiero abrir
class CWndPrueba : public CWnd
{
// Konstruktion
public:
CWndPrueba();
BOOL MakeChild (LPCTSTR szWindowTitle, DWORD dwStyle, RECT &rect, CWnd*
pParentWnd, UINT nID = NULL);
void RespondToParent ();
}
---------------------------
//Fichero de implementacion de la ventana que quiero abrir
CWndPrueba::CWndPrueba ()
{
}
BOOL CWndPrueba::MakeChild (LPCTSTR szWindowTitle, DWORD dwStyle, RECT &rect, CWnd* pParentWnd, UINT nID)
{
CBrush yellowBrush(RGB(255, 255, 0));
CString ChildWindowClass =
AfxRegisterWndClass( CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW,
AfxGetApp()->LoadStandardCursor(IDC_WAIT),
(HBRUSH)yellowBrush.GetSafeHandle(),AfxGetApp()->LoadStandardIcon(IDI_HAND));
AfxMessageBox ("Estoy dentro");
CWnd::Create(ChildWindowClass, szWindowTitle, dwStyle, rect, pParentWnd, nID);
return TRUE;
}
CWndPrueba::~CWndPrueba ()
{
}
--------------------------
//Codigo donde llamo a la ventana
void CFPSView::OnAdd2elem()
{
CWndPrueba wndPrueba;
CRect ChildRect(10, 30, 210, 180);
wndPrueba.MakeChild("Child Window",
WS_CAPTION | WS_THICKFRAME | WS_VISIBLE | WS_MINIMIZEBOX |
WS_MAXIMIZEBOX | WS_SYSMENU, ChildRect, this, NULL);
//AfxMessageBox ("esperando");
}
La cosa esta en que la ventana se crea y se hace visible, pero se cierra automaticamente dandome el siguiente mensaje en el debugger:
Warning: calling DestroyWindow in CWnd::~CWnd; OnDestroy or PostNcDestroy in derived class will not be called.
PumpMessage: hwnd=0x0000, msg = MSUIM.Msg.Private (0x0011, 0x000A0AA6)
Y si le quito el destructor a la clase CWndPrueba, entonces me da los siguientes errores al compilar:
FPSView.obj : error LNK2001: Simbolo externo sin resolver "public: virtual __thiscall CWndPrueba::~CWndPrueba(void)" (??1CWndPrueba@@UAE@XZ)
WndPrueba.obj : error LNK2001: Simbolo externo sin resolver "public: virtual __thiscall CWndPrueba::~CWndPrueba(void)" (??1CWndPrueba@@UAE@XZ)
Debug/FPS.exe : fatal error LNK1120: 1 Referencia externa sin resolver
Alguien me puede decir que estoy haciendo mal? O que tengo que modificar para que la ventana no se destruya sola? POR FAVOR.
resulta que estoy intentando crear ventanas adicionales en mi proyecto ya resulta que las crea, pero que las cierra automaticamente sin casi dar tiempo a verlas. Yo veo la ventana gracias a un AfxMessageBox que le pongo pa detener el sistema, si no... nada.
Lo que he hecho es lo siguiente:
//Fichero cabecera de la ventana que quiero abrir
class CWndPrueba : public CWnd
{
// Konstruktion
public:
CWndPrueba();
BOOL MakeChild (LPCTSTR szWindowTitle, DWORD dwStyle, RECT &rect, CWnd*
pParentWnd, UINT nID = NULL);
void RespondToParent ();
}
---------------------------
//Fichero de implementacion de la ventana que quiero abrir
CWndPrueba::CWndPrueba ()
{
}
BOOL CWndPrueba::MakeChild (LPCTSTR szWindowTitle, DWORD dwStyle, RECT &rect, CWnd* pParentWnd, UINT nID)
{
CBrush yellowBrush(RGB(255, 255, 0));
CString ChildWindowClass =
AfxRegisterWndClass( CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW,
AfxGetApp()->LoadStandardCursor(IDC_WAIT),
(HBRUSH)yellowBrush.GetSafeHandle(),AfxGetApp()->LoadStandardIcon(IDI_HAND));
AfxMessageBox ("Estoy dentro");
CWnd::Create(ChildWindowClass, szWindowTitle, dwStyle, rect, pParentWnd, nID);
return TRUE;
}
CWndPrueba::~CWndPrueba ()
{
}
--------------------------
//Codigo donde llamo a la ventana
void CFPSView::OnAdd2elem()
{
CWndPrueba wndPrueba;
CRect ChildRect(10, 30, 210, 180);
wndPrueba.MakeChild("Child Window",
WS_CAPTION | WS_THICKFRAME | WS_VISIBLE | WS_MINIMIZEBOX |
WS_MAXIMIZEBOX | WS_SYSMENU, ChildRect, this, NULL);
//AfxMessageBox ("esperando");
}
La cosa esta en que la ventana se crea y se hace visible, pero se cierra automaticamente dandome el siguiente mensaje en el debugger:
Warning: calling DestroyWindow in CWnd::~CWnd; OnDestroy or PostNcDestroy in derived class will not be called.
PumpMessage: hwnd=0x0000, msg = MSUIM.Msg.Private (0x0011, 0x000A0AA6)
Y si le quito el destructor a la clase CWndPrueba, entonces me da los siguientes errores al compilar:
FPSView.obj : error LNK2001: Simbolo externo sin resolver "public: virtual __thiscall CWndPrueba::~CWndPrueba(void)" (??1CWndPrueba@@UAE@XZ)
WndPrueba.obj : error LNK2001: Simbolo externo sin resolver "public: virtual __thiscall CWndPrueba::~CWndPrueba(void)" (??1CWndPrueba@@UAE@XZ)
Debug/FPS.exe : fatal error LNK1120: 1 Referencia externa sin resolver
Alguien me puede decir que estoy haciendo mal? O que tengo que modificar para que la ventana no se destruya sola? POR FAVOR.
Valora esta pregunta


0