|
-
January 3rd, 2006, 01:33 AM
#1
MFC question -- updation problem
HI,
There are two classes A and B as follows
class A
{
public:
update_host(CString hostname);
}
class B
{
public:
get_hostname();
}
The get_hostname() gets the hosts name and then calls update_host as folows
A aobject;
aobject.update_host(CString hostname);
now this is what i do in update_host(CString hostname)
update_host(CString hostname)
{
m_hostname=hostname;
UpdateData(FALSE) //to update the value in the edit box.
}
now,when i execute it,i get the error saying
Debug assertion failed.
file:wincore.cpp
line:3095.
Please help in this regards.
Thank you.
-
January 3rd, 2006, 02:36 AM
#2
Re: MFC question -- updation problem
Well...is class A derived from a dialog class? 'UpdateData()' needs the context of the dialog class in order to update values...
-
January 3rd, 2006, 04:07 AM
#3
Re: MFC question -- updation problem
Yes,Exactly the class A is derived from dialog class.and i am using its context.then also i am getting error.
Last edited by harshandu; January 3rd, 2006 at 04:19 AM.
-
January 3rd, 2006, 04:30 AM
#4
Re: MFC question -- updation problem
Where is the DoDataExchange function !
-
January 3rd, 2006, 04:56 AM
#5
Re: MFC question -- updation problem
DoDataExchange function is in class B.
-
January 3rd, 2006, 05:15 AM
#6
Re: MFC question -- updation problem
DoDataExchange must be in the class that calls UpdateData
-
January 3rd, 2006, 06:56 AM
#7
Re: MFC question -- updation problem
From your code snippet I am guessing that A defines a dialog - if that's true, then the problem is:
Code:
The get_hostname() gets the hosts name and then calls update_host as folows
A aobject;
aobject.update_host(CString hostname);
now this is what i do in update_host(CString hostname)
update_host(CString hostname)
{
m_hostname=hostname;
UpdateData(FALSE) //to update the value in the edit box.
}
You have created an object (aobject) but at this point the window(s) have not been created. This happens when you call DoModal (or Create if modeless).
Until the windows exist, UpdateData will fail.
You'll need to update the windows after the call to CDialog::OnInitDialog inside your overridden OnInitDialog function.
Hope that helps.
Be sure to rate those who help!
-------------------------------------------------------------
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|