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 :
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; }
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.