Click here to Skip to main content
15,896,726 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: calling int 21h from a __asm block of code Pin
CorvetteZ06067-Aug-05 3:37
CorvetteZ06067-Aug-05 3:37 
GeneralRe: calling int 21h from a __asm block of code Pin
John R. Shaw8-Aug-05 18:39
John R. Shaw8-Aug-05 18:39 
GeneralRe: calling int 21h from a __asm block of code Pin
Alexander M.,7-Aug-05 4:38
Alexander M.,7-Aug-05 4:38 
GeneralRe: calling int 21h from a __asm block of code Pin
Gary R. Wheeler7-Aug-05 4:52
Gary R. Wheeler7-Aug-05 4:52 
GeneralRe: calling int 21h from a __asm block of code Pin
CorvetteZ06067-Aug-05 6:08
CorvetteZ06067-Aug-05 6:08 
GeneralRe: calling int 21h from a __asm block of code Pin
David Crow8-Aug-05 8:42
David Crow8-Aug-05 8:42 
GeneralRe: calling int 21h from a __asm block of code Pin
Gary R. Wheeler8-Aug-05 12:56
Gary R. Wheeler8-Aug-05 12:56 
GeneralFailing Debug Assertion in DoModal() Pin
gremlinimp6-Aug-05 19:20
gremlinimp6-Aug-05 19:20 
Summary:
m_hWnd is NULL in a CDialog derived class and this leads to an assertion failure.

Details:
I am writing an SDI application. I've subclassed a CDialog class that will popup and gather info from the user. In response to the user clicking some button the Document class handles the message and creates a new CDialog object and calls DoModal(). The basic idea is something like this:
<br />
void CMyDoc::OnButtonClick()<br />
{<br />
   CMyDialog md;<br />
   md.DoModal();<br />
   //gather info from md ...<br />
}


Now, the CMyDialog class has a CTabCtrl named "m_tabSettings" with two tabs. I need to initialize these tabs and have tried to do so with code similar to this:

<br />
   m_tabSettings.InsertItem(0,"Tab One");<br />
   m_tabSettings.InsertItem(1,"Tab Two");<br />


This causes an assertion failure in AFXCMN.INL on the following line:

<br />
//cut paste from afxmn.inl :<br />
_AFXCMN_INLINE BOOL CTabCtrl::InsertItem(int nItem, LPCTSTR lpszItem)<br />
	{ ASSERT(::IsWindow(m_hWnd)); return CTabCtrl::InsertItem(TCIF_TEXT, nItem, lpszItem, 0, 0); }<br />


The key part from above is: ASSERT(::IsWindow(m_hWnd));

I stepped through this code in the debugger and sure enough m_hWnd is 0x00 when I try to insert tabs into my CTabCtrl. I'v tried the following:
1. moving this 'insert item' code to the CMyDialog constructor (actually this is where I had it to begin with)
2. moving the 'insert item' code to a separate function which I call between the dialog declaration and DoModal()
3. changing the CMyDialog variable to a pointer and creating a 'new CMyDialog' on the heap
4. calling CMyDialog::Create() before the call to DoModal() ... and I played with creating a CMyDialog object from the CMyView class as well.
5. getting rid of the tab control initialization code altogether and inserting a CListCtrl in report form as a variable instead. I then tried to call CListCtrl::InsertColumn(0,"col one") ... etc.

All of these cause the same or similar assertion errors. I know, most of the stuff I've tried is some type of 'magic chicken coding' but I have no idea why code that I've pretty much copied from stuff I saw on the MSDN is breaking like this (i.e. I'm out of ideas)Confused | :confused: .

Is there some order of method calls that I'm missing or some flag for the CMyDialog?
If anyone has had a similar problem please let me know if and how they've fixed it.
GeneralRe: Failing Debug Assertion in DoModal() Pin
Jose Lamas Rios6-Aug-05 20:23
Jose Lamas Rios6-Aug-05 20:23 
GeneralRe: Failing Debug Assertion in DoModal() Pin
gremlinimp6-Aug-05 20:47
gremlinimp6-Aug-05 20:47 
GeneralRe: Failing Debug Assertion in DoModal() Pin
gremlinimp6-Aug-05 20:49
gremlinimp6-Aug-05 20:49 
GeneralLarge Array Implementing Pin
Majid Shahabfar6-Aug-05 19:07
Majid Shahabfar6-Aug-05 19:07 
GeneralRe: Large Array Implementing Pin
John R. Shaw6-Aug-05 22:09
John R. Shaw6-Aug-05 22:09 
GeneralClistControl giving exceptions Pin
Aditya Rao6-Aug-05 17:38
Aditya Rao6-Aug-05 17:38 
GeneralRe: ClistControl giving exceptions Pin
Tim Smith6-Aug-05 18:07
Tim Smith6-Aug-05 18:07 
QuestionMultislider control? Pin
Ravi Bhavnani6-Aug-05 14:00
professionalRavi Bhavnani6-Aug-05 14:00 
AnswerFound it! Pin
Ravi Bhavnani6-Aug-05 14:39
professionalRavi Bhavnani6-Aug-05 14:39 
GeneralRe: Found it! Pin
Steve Mayfield6-Aug-05 18:26
Steve Mayfield6-Aug-05 18:26 
GeneralRe: Found it! Pin
Ravi Bhavnani6-Aug-05 18:29
professionalRavi Bhavnani6-Aug-05 18:29 
GeneralRe: Found it! Pin
Trollslayer6-Aug-05 23:25
mentorTrollslayer6-Aug-05 23:25 
GeneralOdd MessageBox Problem Pin
sir kaber6-Aug-05 13:43
sir kaber6-Aug-05 13:43 
GeneralRe: Odd MessageBox Problem Pin
sir kaber6-Aug-05 13:49
sir kaber6-Aug-05 13:49 
GeneralRe: Odd MessageBox Problem Pin
John R. Shaw7-Aug-05 0:22
John R. Shaw7-Aug-05 0:22 
GeneralRe: Odd MessageBox Problem Pin
sir kaber7-Aug-05 9:00
sir kaber7-Aug-05 9:00 
GeneralDialog problems with VC6.0 built under XP Pin
Haakon S.6-Aug-05 12:36
Haakon S.6-Aug-05 12:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.