我正在尝试从 MFC C++ 中的 IP 地址控件获取 IP 地址。但它返回一个错误ASSERT(::IsWindow(m_hWnd)); return (int) ::SendMessage(m_hWnd, IPM_GETADDRESS, 0, (LPARAM) &dwAddress); }
这是我所做的代码。错误是在这一行产生的Dlg.m_IPAdd.GetAddress(IP2);
BOOL CProxyCardSimulatorDlg::OnInitDialog()
{
CLogin Dlg;
bool isDbConnected;
Dlg.DoModal();
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
CRect rect;
ConsoleLog.GetClientRect(&rect);
ConsoleLog.InsertColumn(0, _T(" "), LVCFMT_LEFT, rect.Width());
LONG style = ::GetWindowLong(m_IDEnter.m_hWnd, GWL_STYLE);
style |= ES_NUMBER;
::SetWindowLong(m_IDEnter.m_hWnd, GWL_STYLE, style);
m_IDEnter.SetLimitText(6);
DWORD IP2;
Dlg.m_IPAdd.GetAddress(IP2); // ERROR HERE
if(true == serverConnect(IP))
{
addData(ConsoleLog,rec,0,9);
}
return TRUE; // return TRUE unless you set the focus to a control
}