Click here to Skip to main content
15,887,477 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
how to differenciate the empty value (. . . .) and 0.0.0.0 in ip address control

What I have tried:

I'm getting the ip address 0.0.0.0 correctly but its not setting on the cedit its just showing blank
Posted
Updated 20-Apr-17 23:10pm
Comments
Kats2512 21-Apr-17 5:08am    
What I have tried:

I'm getting the ip address 0.0.0.0 correctly but its not setting on the cedit its just showing blank

is not actually showing any of us what you have tried! put some code in order for people to assist!
Member 13089825 21-Apr-17 5:57am    
sorry I have missed previsously

when I used below thing
CWnd* pwndCtrl = GetFocus();
int ctrl_ID = pwndCtrl->GetDlgCtrlID();
if (!((CIPAddressCtrl*)pwndCtrl)->IsBlank()) {

AfxMessageBox(L"not empty");
}
its always going to inside(printing not empty)
could you please suggest me how to show 0.0.0.0 on cedit

1 solution

See CIPAddressCtrl Class[^]. The class provides the IsBlank() method to check if all fields are empty and GetAddress() returns the number of non-empty fields.
 
Share this answer
 
Comments
Member 13089825 21-Apr-17 5:57am    
thank you for your reply.
when I hused below thing
CWnd* pwndCtrl = GetFocus();
int ctrl_ID = pwndCtrl->GetDlgCtrlID();
if (!((CIPAddressCtrl*)pwndCtrl)->IsBlank()) {

AfxMessageBox(L"not empty");
}
its always going to inside(printing not empty)
could you please suggest me how to show 0.0.0.0 on cedit
Jochen Arndt 21-Apr-17 6:14am    
Do you have an IP address control or an edit control?
From where you are calling the above code?

GetFocus() returns the control that has the focus. This might be any control and not the IP address control.

If you call that from the dialog containing that control use
CIPAddressCtrl* pCtrl = (CIPAddressCtrl*)GetDlgItem(ID_OF_IP_ADDRD_CTRL);
if (pCtrl->IsBalnk())
and replace the ID with one used in your application.

Or if you have a member variable for the control use that.
Member 13089825 21-Apr-17 6:28am    
I'm using the edit control
when I did below thing
CIPAddressCtrl* pCtrl = (CIPAddressCtrl*)GetDlgItem(IDC_EDIT_IP_RANGE_START);
if (pCtrl->IsBlank())//Nonzero if all of the IP Address Control fields are empty; otherwise 0
{
AfxMessageBox(L" empty");


}
its coming as empty after enter the values as 0.0.0.0
Jochen Arndt 21-Apr-17 6:59am    
If you have a CEdit control you can't cast it to a CIPAddressCtrl.

I assumed a CIPAddressCtrl beacuse the subject of your question is "Ip address control".

If you have a CEdit control with an input mask, you have to implement the checking yourself (e.g. by using GetWindowText() and checking the content).

NOTE:
When using GetDlgItem() cast to the exact type of the control referenced by the ID. Anything else will not work and might let your application crash.
Member 13089825 21-Apr-17 6:35am    
whenever entering as 0.0.0.0 its considering as empty (blank)and its not displaying on edit control.
(as per you suggestion I have checked the blanked state for each edit control.
whatever input contain 0.0.0.0. its considering as blank.
could you please suggest how to show 0.0.0.0 on edit control

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900