|
Hai,
I am trying to add contents to list box but i am getting run time error (VC++ Debug Library)
Can anyone help me with this.
I used F10 and checked run time error was generated at this line
status.m_OUT.AddString(e->filename);
void Index :: readFiles (sortentry* e)
{
---
----
----
if ((s = (char*)strrchr(e->filename, '/')) == NULL)
{
CStatusDlg status;
status.m_OUT.AddString(e->filename);
}
}
Regards,
Vinay Charan CN.
|
|
|
|
|
Is the listbox created when you add items to it?
The usual place to intiate controls is in OnInitDialog.
|
|
|
|
|
you use
CStatusDlg status;
status.m_OUT.AddString(e->filename);
I guess m_OUT.m_hWnd is NULL
whitesky
|
|
|
|
|
Hai,
So what shd be done ??? Can u help me with this.
|
|
|
|
|
I tested like this
<br />
CAnswer m_Answer;<br />
m_Answer.m_List1.AddString("A");
hWnd=0x0000 and m_Answer.m_List1 is=0x0000<br />
--------------------
of course CTest2 is CDialog
you can use of course i suggest you created your dialog in one function like OnInitDialog
and you can use from it
<br />
CAnswer m_Answer;<br />
m_Answer.Create(IDD_TEST2);<br />
m_Answer.m_List1.AddString("A");<br />
m_dlg and handle from List is valid
whitesky
|
|
|
|
|
Hai,
I made the changes as below as u said but still i am getting error.
void Index :: readFiles (sortentry* e)
{
FILE *fp;
char *s;
static int fnum = 0;
int wds = 0;
if (e != NULL) {
readFiles (e->left);
fp = fopen (e->filename, "r");
fnum++;
CStatusDlg status;
status.Create(IDD_INDEX_STATUS_DIALOG);
if ((s = (char*)strrchr(e->filename, '/')) == NULL)
{
status.m_OUT.AddString(e->filename);
}
else
{
status.m_OUT.AddString(e->filename);
}
---
=----
}
|
|
|
|
|
what is it sortentry* e?
whitesky
|
|
|
|
|
Hai,
it just Receives file names from other functions.
|
|
|
|
|
|
(VC++ Debug Library)
status.m_OUT.AddString(e->filename);
|
|
|
|
|
Check this:
status.GetSafeHwnd() ==NULL?
m_OUT is ==NULL?
m_OUT->GetSafeHwnd() ==NULL?
e->filename is CString? Empty?
|
|
|
|
|
hi,
how to check the values for status.GetSafeHwnd() ??
//m_OUT is ==NULL?
m_OUT will be empty when the dialog loads.
//e->filename is CString? Empty?
e value will alwys have a value its of CString type "C:\Dir\filename1"
|
|
|
|
|
You have to write code like this (according to your variable definitions)
and find out what is the object with the real problem.
CStatusDlg status;<br />
status.Create(IDD_INDEX_STATUS_DIALOG);<br />
<br />
ASSERT(status.GetSafeHwnd() != NULL);<br />
ASSERT(status.m_OUT.GetSafeHwnd() != NULL);<br />
ASSERT(e != NULL);<br />
ASSERT(e->filename != "");<br />
...<br />
<br />
status.m_OUT.AddString(e->filename);
You must add every test that could be a problem during execution, and, remember, use DEBUG mode, not RELEASE.
If there is a bug the program will stops at the line that point the problem.
|
|
|
|
|
Hi,
i have used f10 and check the exact line where the error generates
status.Create(IDD_INDEX_STATUS_DIALOG);
305: status.Create(IDD_INDEX_STATUS_DIALOG);
0040A83B push 0
0040A83D push 84h
0040A842 lea ecx,[status]
0040A848 call CDialog::Create (00409e36)
what will be cause ??
------------------------------
void Index :: readFiles (sortentry* e)
{
FILE *fp;
char *s;
static int fnum = 0;
int wds = 0;
if (e != NULL) {
readFiles (e->left);
fp = fopen (e->filename, "r");
fnum++;
CStatusDlg status;
status.Create(IDD_INDEX_STATUS_DIALOG);
if ((s = (char*)strrchr(e->filename, '/')) == NULL)
{
ASSERT(status.GetSafeHwnd() != NULL);
ASSERT(status.m_OUT.GetSafeHwnd() != NULL);
ASSERT(e != NULL);
ASSERT(e->filename != "");
status.m_OUT.AddString(e->filename);
}
else
{
ASSERT(status.GetSafeHwnd() != NULL);
ASSERT(status.m_OUT.GetSafeHwnd() != NULL);
ASSERT(e != NULL);
ASSERT(e->filename != "");
status.m_OUT.AddString(e->filename);
}
// cout <<" " << s+1;
insert (fnum, e->filename);
if (fp) {
wds = getWord (fp,fnum);
}
else {
cerr << "File: " << e->filename << " can't open" << endl;
return;
}
cout << " (" << wds << " words)" << endl;
fclose (fp);
free (e->filename);
readFiles(e->right);
delete e;
}
}
|
|
|
|
|
CStatusDlg is child of CDialog?
Check if IDD_INDEX_STATUS_DIALOG is the right id of a Dialog resource.
else follow the functions's call using F11, and, surely, you will find the point that give the error.
|
|
|
|
|
Possible error:
CStatusDlg status;<br />
status.Create(IDD_INDEX_STATUS_DIALOG);
->Use this:
CStatusDlg status(IDD_INDEX_STATUS_DIALOG);
|
|
|
|
|
Hi,
i did that i am getting compile time error
CStatusDlg status(IDD_INDEX_STATUS_DIALOG);
'CStatusDlg::CStatusDlg' : cannot convert parameter 1 from 'const int' to 'class CWnd *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
|
|
|
|
|
Then, follow the create function using F10 and F11.
Be sure that the ID (and resource object) IDD_INDEX_STATUS_DIALOG is correct.
|
|
|
|
|
Hai,
I have checked the Dialog ID its correct.
I am not able to trace with f11, how to do that ?? its keep on entering the loop its not breaking.
|
|
|
|
|
Simply press F11 in place of F10 when you want to show the code of a called function (in your case Create )
|
|
|
|
|
fp = fopen (e->filename, "r");<br />
...<br />
if ((s = (char*)strrchr(e->filename, '/')) == NULL)
mmm....
fp = fopen (e->filename, "r");<br />
...<br />
if ((s = (char*)strrchr(e->filename, '\\')) == NULL)
Is this a good correction?
|
|
|
|
|
Hi,
I have checked with out adding items it works corectly whn i add the additems to list box i am getting error.
|
|
|
|
|
can you please show the value of e->fileName ?
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[V]--
[My Current Status]
|
|
|
|
|
hi,
It hold the value like c:\path\dir\filename1 that it
|
|
|
|
|