Click here to Skip to main content
15,905,010 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to use the CIPAddressCtrl and it has a very odd problem. When I use it in an dialog-based application's primary dialog it works correctly. When I use it in a pop-up dialog the problem appears - it does not accept three-digit address bytes.

Does anyone know what's going on with this?

What I have tried:

I tried to set the field ranges to go up to 255 and that made no difference. I tried Hans Dietrich's enhanced version here and it works correctly as it is the app's primary dialog. I added a button to his test app's main dialog that would bring up a secondary dialog and the problem showed up again. Here's the dialog code in case anyone wants to try it :
C++
class CCtrlTestDlg : public CDialog
{
public:
	CCtrlTestDlg( CWnd* pParent = NULL ) : CDialog( IDD, pParent ) {}

	enum { IDD = IDD_TEST_DIALOG };

	CIPAddressCtrl		m_Address;

protected:
	virtual void DoDataExchange( CDataExchange* pDX )
	{
		__super::DoDataExchange( pDX );

		DDX_Control( pDX, IDC_TEST_ADDRESS, m_Address );
	}

	virtual BOOL OnInitDialog()
	{
		__super::OnInitDialog();
		return TRUE;  // return TRUE  unless you set the focus to a control
	}

	DECLARE_MESSAGE_MAP()
};

BEGIN_MESSAGE_MAP( CCtrlTestDlg, CDialog )
END_MESSAGE_MAP()
This uses a dialog with ID IDD_TEST_DIALOG and it has an IP Address control with ID IDC_TEST_ADDRESS and an OK button and that's it. I added a button to the app's dialog and when clicked it does this :
void CXIPAddressCtrlTestDlg::OnTestControl()
{
	CCtrlTestDlg dlg( this );
	dlg.DoModal();
}
The dialog resource is :
IDD_TEST_DIALOG DIALOGEX 0, 0, 180, 98
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION
CAPTION "Control Test"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
    DEFPUSHBUTTON   "OK",IDOK,32,58,46,22
    PUSHBUTTON      "Cancel",IDCANCEL,100,58,46,22
    LTEXT           "Enter an Address:",IDC_STATIC,20,22,58,14,SS_CENTERIMAGE
    CONTROL         "IPAddress2",IDC_TEST_ADDRESS,"SysIPAddress32",WS_TABSTOP,81,22,74,14
END
and that's all there is to the testing dialog. This dialog can be added to practically any MFC app to check things out.

Two other pieces of info: when I remove the MFC subclassed control the same thing happens. Also, when I enter a third digit the control receives a command message of EN_MAXTEXT. That's the problem - I can't enter an address with any value above 99.
Posted
Updated 7-Jan-19 10:40am
v4
Comments
Rick York 7-Jan-19 15:24pm    
A little more info - the issue is not with MFC's subclassing because the base control exhibits the same behavior when there is no MFC control declared.
Losiem 29-Mar-22 9:11am    
I have the same problem.
On some machines (very few) I cannot enter 3rd digit.
Has anyone found the cause of the problem?

1 solution

I don't have MFC but testing your dialog as a popup it works fine. You need to provide some more details about exactly what happens when you run your application. And what is CXIPAddressCtrl, I cannot find its reference?
 
Share this answer
 
Comments
Rick York 7-Jan-19 16:29pm    
That is Hans Dietrich's enhanced version. I used it because he has a testing app available for it too. That can be replaced by removing the X from the name and changing this method to look like this:
	virtual BOOL OnInitDialog()
	{
		__super::OnInitDialog();
		return TRUE;  // return TRUE  unless you set the focus to a 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