what is wrong in this code
-
CIPAddressCtrl *ip = (CIPAddressCtrl *)GetDlgItem(13); ip->GetAddress(dwIPAddress); 13 is a control id that was i created dynamically
What is the problem ? Did you check with your debugger that ip is a valid pointer before calling GetAddress ?
Cédric Moonen Software developer
Charting control [v1.2] -
CIPAddressCtrl *ip = (CIPAddressCtrl *)GetDlgItem(13); ip->GetAddress(dwIPAddress); 13 is a control id that was i created dynamically
Check if the control identifier (13) was already assigned by AppWizard to any other control.:)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
-
CIPAddressCtrl *ip = (CIPAddressCtrl *)GetDlgItem(13); ip->GetAddress(dwIPAddress); 13 is a control id that was i created dynamically
Whats return value in
ip
?
WhiteSky
-
Whats return value in
ip
?
WhiteSky
-
CIPAddressCtrl *ip = (CIPAddressCtrl *)GetDlgItem(13); ip->GetAddress(dwIPAddress); 13 is a control id that was i created dynamically
prathuraj wrote:
CIPAddressCtrl *ip = (CIPAddressCtrl *)GetDlgItem(13);
Unless , you are having the control with id 13, nothing wrong with code. Though, I would have used
dynamic_cast
, instead of c-style cast.prathuraj wrote:
ip->GetAddress(dwIPAddress);
If
ip
is non-null and controll retunrned in previous statement is of typeCIPAddressCtrl
, there should not be any problem. Can you specify, what problem you are facing.
Prasad MS MVP - VC++
-
prathuraj wrote:
CIPAddressCtrl *ip = (CIPAddressCtrl *)GetDlgItem(13);
Unless , you are having the control with id 13, nothing wrong with code. Though, I would have used
dynamic_cast
, instead of c-style cast.prathuraj wrote:
ip->GetAddress(dwIPAddress);
If
ip
is non-null and controll retunrned in previous statement is of typeCIPAddressCtrl
, there should not be any problem. Can you specify, what problem you are facing.
Prasad MS MVP - VC++
-
As sated in one of previous post, make sure, id 13 is assigned to control you are talking about.
Prasad MS MVP - VC++
-
prathuraj wrote:
Access violation error occured at this line
Because ip is invalid.
WhiteSky
-
As sated in one of previous post, make sure, id 13 is assigned to control you are talking about.
Prasad MS MVP - VC++
-
I want to get a value from dynamic ip address control for that purpose i wrote this code CIPAddressCtrl* ip = (CIPAddressCtrl *)GetDlgItem(13); ip->GetAddress(dword);
How do you make this control?
WhiteSky
-
CIPAddressCtrl *ip = (CIPAddressCtrl *)GetDlgItem(13); ip->GetAddress(dwIPAddress); 13 is a control id that was i created dynamically
Try this code instead (run in a debug build):
CWnd *pWnd = GetDlgItem(13);
ASSERT(pWnd != NULL);
ASSERT(dynamic_cast<CIPAddressCtrl*>(pWnd) != NULL);
CIPAddressCtrl *ip = static_cast<CIPAddressCtrl*>(pWnd);If the second line asserts in a debug build the id is wrong. If the third line asserts in a debug build the
CWnd
returned was not aCIPAddressCtrl
and your cast is in error. Try adding a member variable (using ClassWizard in MSVC6); this step makes callingGetDlgItem
unnecessary. If this line fails to compile enable RTTI (just in the debug build) and try again. If the fourth line fails to compileCIPAddressCtrl
is not derived fromCWnd
. Don't use C-style casts!Steve
-
CIPAddressCtrl *ip = (CIPAddressCtrl *)GetDlgItem(13); ip->GetAddress(dwIPAddress); 13 is a control id that was i created dynamically
Typically, the wizards assign control IDs starting at 1000 - perhaps the ID you chose (13) is actually some other control that has been assigned by Microsoft. It could be that by simply changing your ID (perhaps to something like above 1000, you may be ok as long as that ID isn't used elsewhere in your project. Hope that helps.
Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193