October 13th, 2011, 10:28 AM
mfc ASSERT(::IsWindow(m_hWnd)) issue, not sure what's wrong
I'm having a bug in my code that's kicking my ***, so after much attempted debugging I finally decided to see if anyone else knew what my issue was.
I'm trying to add a grid object to a dialog that I have, but I keep hitting the assert in the title and I don't know why.
Any idea what's going on? I mean, I only create the dialog once everything has been initalized, so there shouldn't be a problem there. m_Grid.Create() returns true, so creation is successful. Why is SetRedraw() hitting the assert that the m_hWnd isn't a handle to a window? Where does m_hWnd get set anyway?
LONG myDialog::OnInitDialog(UINT wParam, LONG lParam)
BOOL bRet = super::OnInitDialog();
RefMemberDelegate1(*this, &myDialog::OnNewDoc), this); //attach to event so I know when document is created
void myDialog::OnNewDoc(CDerivedDocument* pNewDoc)
pNewDoc->SetMyDialog(this); // when new document is created, set pointer to dialog
// Get the grid area rectangle and set it up.
GetDlgItem(IDC_GRID)->MapWindowPoints(this, &rect); //replacing dummy image with the grid
m_Grid = new myGridCtrl;
bool result = m_Grid->Create(WS_CHILD | WS_BORDER | WS_VISIBLE | WS_TABSTOP, rect, this, IDC_GRID);
// Set the appropriate options
m_Grid->InsertColumn(0, _T("Name"), 100); //doesn't seem to crash here, which means grid is creted okay?
void myDialog::PopulateGridControl(BOOL bRedraw, CDerivedDocument * pDoc)
if(GetSafeHwnd() == NULL)
//get handles to document and stuff
m_Grid->SetRedraw(FALSE); // ASSERTS HERE
//In CDocument once it is created...
CDerivedDocument::SetMyDoc(myDialog * pDlg)
Thanks for any help you can offer.
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!