VC6.0中动态数据交换DDX
如下代码
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT1, m_strEdit1);
DDX_Text(pDX, IDC_EDIT2, m_strEdit2);
DDV_MaxChars(pDX, m_strEdit1, 5);
DDV_MaxChars(pDX, m_strEdit2, 5);对Edit1的最多字符限制不起作用!! DDV_MaxChars(pDX, m_strEdit2, 5);
DDX_Text(pDX, IDC_EDIT1, m_strEdit1);
DDX_Text(pDX, IDC_EDIT2, m_strEdit2);
DDV_MaxChars(pDX, m_strEdit1, 5);
这中情况下仍然对Edit1不起作用经过测试发现在最新版的VC.net2003中仍然存在相同的Bug!!!
微软的垃圾!!!!
如下代码
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT1, m_strEdit1);
DDX_Text(pDX, IDC_EDIT2, m_strEdit2);
DDV_MaxChars(pDX, m_strEdit1, 5);
DDV_MaxChars(pDX, m_strEdit2, 5);对Edit1的最多字符限制不起作用!! DDV_MaxChars(pDX, m_strEdit2, 5);
DDX_Text(pDX, IDC_EDIT1, m_strEdit1);
DDX_Text(pDX, IDC_EDIT2, m_strEdit2);
DDV_MaxChars(pDX, m_strEdit1, 5);
这中情况下仍然对Edit1不起作用经过测试发现在最新版的VC.net2003中仍然存在相同的Bug!!!
微软的垃圾!!!!
2.调用窗口的((CEdit*)GetDlgItem(ID_EDIT))->SetLimitText(nMax);你认为的VC存在Bug,那是因为你没有吃透DDX,DDV的机制
我n年以前已经知道了
看来,你跟本不知道MFC有动态数据交换这个问题?
难怪你满嘴的垃圾!
其中有这么一段:The DDV_ routine should immediately follow the DDX_ routine for that field.
是楼主没有按照文档说明的去做.
如果我是楼主,碰到问题首先会察看vc的源代码,而不是上来说垃圾和被说垃圾:DDV_MaxChars(...)
{
......
HWND hWndLastControl;
pDX->m_pDlgWnd->GetDlgItem(pDX->m_idLastControl, &hWndLastControl);
::SendMessage(hWndLastControl, EM_LIMITTEXT, nChars, 0);
......
}显然这里是对pDX->m_idLastControl控件设置最大字符个数,那m_idLastControl是哪里设置的呢?void AFXAPI DDX_Text(CDataExchange* pDX, int nIDC, CString& value)
{
......
HWND hWndCtrl = pDX->PrepareEditCtrl(nIDC);//调用pDX->PrepareCtrl
......
}HWND CDataExchange::PrepareCtrl(int nIDC)
{
......
m_idLastControl = nIDC;
......
}无语......
原来楼主真的是垃圾......