VC中对话框编程出现的问题
编写了一段程序,从对话框中输入数据存储到相应的变量中,但其中出现了问题.下面程序中,赋值号右边的是与对话框中编辑框关联的变量,左边是需要存储的变量.我在调试运行程序时发现...
编写了一段程序,从对话框中输入数据存储到相应的变量中,但其中出现了问题.
下面程序中,赋值号右边的是与对话框中编辑框关联的变量,左边是需要存储的变量.我在调试运行程序时发现当我往编辑框内输入数据后,某些变量能通过关联的编辑框变量赋值,某些就不行.
具体是pDoc->ylpfk[0]=spfk.m_ylpfk1;
pDoc->ylpfk[1]=spfk.m_ylpfk2;
pDoc->ylpfk[2]=spfk.m_ylpfk3;
pDoc->ylsfk[0]=spfk.m_ylsfk1;
pDoc->ylsfk[1]=spfk.m_ylsfk2;
pDoc->ylsfk[2]=spfk.m_ylsfk3;
这些语句,右边的变量值是我输入的值,左边的变量始终得不到右边得值
而pDoc->spfasj=spfk.m_spfasj;
pDoc->zsjpfka[0]=spfk.m_zsj1pA;
pDoc->zsjpfka[1]=spfk.m_zsj2pA;
pDoc->zsjpfka[2]=spfk.m_zsj3pA;
pDoc->zsjpfkd[0]=spfk.m_zsj1pD;
pDoc->zsjpfkd[1]=spfk.m_zsj2pD;
pDoc->zsjpfkd[2]=spfk.m_zsj3pD;
这些语句就能使左边变量得到相应得值.
请高手指点下为什么会出现这种情况
程序段原代码如下:
void CDrawView::OnSpfengkou()
{
// TODO: Add your command handler code here
CSPFENGKDlg spfk;
//CString ss;
CDrawDoc* pDoc = GetDocument();
if(spfk.DoModal()==IDOK)
{
pDoc->spfasj=spfk.m_spfasj;
pDoc->zsjpfka[0]=spfk.m_zsj1pA;
pDoc->zsjpfka[1]=spfk.m_zsj2pA;
pDoc->zsjpfka[2]=spfk.m_zsj3pA;
pDoc->zsjpfkd[0]=spfk.m_zsj1pD;
pDoc->zsjpfkd[1]=spfk.m_zsj2pD;
pDoc->zsjpfkd[2]=spfk.m_zsj3pD;
pDoc->zsjsfka[0]=spfk.m_zsj1sA;
pDoc->zsjsfka[1]=spfk.m_zsj2sA;
pDoc->zsjsfka[2]=spfk.m_zsj3sA;
pDoc->zsjsfkd[0]=spfk.m_zsj1sD;
pDoc->zsjsfkd[1]=spfk.m_zsj2sD;
pDoc->zsjsfkd[2]=spfk.m_zsj3sD;
pDoc->zlpfk[0]=spfk.m_zlpfk1;
pDoc->zlpfk[1]=spfk.m_zlpfk2;
pDoc->zlpfk[2]=spfk.m_zlpfk3;
pDoc->zlsfk[0]=spfk.m_zlsfk1;
pDoc->zlsfk[1]=spfk.m_zlsfk2;
pDoc->zlsfk[2]=spfk.m_zlsfk3;
pDoc->ysjpfka[0]=spfk.m_ysj1pA;
pDoc->ysjpfka[1]=spfk.m_ysj2pA;
pDoc->ysjpfka[2]=spfk.m_ysj3pA;
pDoc->ysjpfkd[0]=spfk.m_ysj1pD;
pDoc->ysjpfkd[1]=spfk.m_ysj2pD;
pDoc->ysjpfkd[2]=spfk.m_ysj3pD;
pDoc->ysjsfka[0]=spfk.m_ysj1sA;
pDoc->ysjsfka[1]=spfk.m_ysj2sA;
pDoc->ysjsfka[2]=spfk.m_ysj3sA;
pDoc->ysjsfkd[0]=spfk.m_ysj1sD;
pDoc->ysjsfkd[1]=spfk.m_ysj2sD;
pDoc->ysjsfkd[2]=spfk.m_ysj3sD;
pDoc->ylpfk[0]=spfk.m_ylpfk1;
pDoc->ylpfk[1]=spfk.m_ylpfk2;
pDoc->ylpfk[2]=spfk.m_ylpfk3;
pDoc->ylsfk[0]=spfk.m_ylsfk1;
pDoc->ylsfk[1]=spfk.m_ylsfk2;
pDoc->ylsfk[2]=spfk.m_ylsfk3;
pDoc->pfkv=spfk.m_pfkv;
pDoc->sfkv=spfk.m_sfkv;
}
} 展开
下面程序中,赋值号右边的是与对话框中编辑框关联的变量,左边是需要存储的变量.我在调试运行程序时发现当我往编辑框内输入数据后,某些变量能通过关联的编辑框变量赋值,某些就不行.
具体是pDoc->ylpfk[0]=spfk.m_ylpfk1;
pDoc->ylpfk[1]=spfk.m_ylpfk2;
pDoc->ylpfk[2]=spfk.m_ylpfk3;
pDoc->ylsfk[0]=spfk.m_ylsfk1;
pDoc->ylsfk[1]=spfk.m_ylsfk2;
pDoc->ylsfk[2]=spfk.m_ylsfk3;
这些语句,右边的变量值是我输入的值,左边的变量始终得不到右边得值
而pDoc->spfasj=spfk.m_spfasj;
pDoc->zsjpfka[0]=spfk.m_zsj1pA;
pDoc->zsjpfka[1]=spfk.m_zsj2pA;
pDoc->zsjpfka[2]=spfk.m_zsj3pA;
pDoc->zsjpfkd[0]=spfk.m_zsj1pD;
pDoc->zsjpfkd[1]=spfk.m_zsj2pD;
pDoc->zsjpfkd[2]=spfk.m_zsj3pD;
这些语句就能使左边变量得到相应得值.
请高手指点下为什么会出现这种情况
程序段原代码如下:
void CDrawView::OnSpfengkou()
{
// TODO: Add your command handler code here
CSPFENGKDlg spfk;
//CString ss;
CDrawDoc* pDoc = GetDocument();
if(spfk.DoModal()==IDOK)
{
pDoc->spfasj=spfk.m_spfasj;
pDoc->zsjpfka[0]=spfk.m_zsj1pA;
pDoc->zsjpfka[1]=spfk.m_zsj2pA;
pDoc->zsjpfka[2]=spfk.m_zsj3pA;
pDoc->zsjpfkd[0]=spfk.m_zsj1pD;
pDoc->zsjpfkd[1]=spfk.m_zsj2pD;
pDoc->zsjpfkd[2]=spfk.m_zsj3pD;
pDoc->zsjsfka[0]=spfk.m_zsj1sA;
pDoc->zsjsfka[1]=spfk.m_zsj2sA;
pDoc->zsjsfka[2]=spfk.m_zsj3sA;
pDoc->zsjsfkd[0]=spfk.m_zsj1sD;
pDoc->zsjsfkd[1]=spfk.m_zsj2sD;
pDoc->zsjsfkd[2]=spfk.m_zsj3sD;
pDoc->zlpfk[0]=spfk.m_zlpfk1;
pDoc->zlpfk[1]=spfk.m_zlpfk2;
pDoc->zlpfk[2]=spfk.m_zlpfk3;
pDoc->zlsfk[0]=spfk.m_zlsfk1;
pDoc->zlsfk[1]=spfk.m_zlsfk2;
pDoc->zlsfk[2]=spfk.m_zlsfk3;
pDoc->ysjpfka[0]=spfk.m_ysj1pA;
pDoc->ysjpfka[1]=spfk.m_ysj2pA;
pDoc->ysjpfka[2]=spfk.m_ysj3pA;
pDoc->ysjpfkd[0]=spfk.m_ysj1pD;
pDoc->ysjpfkd[1]=spfk.m_ysj2pD;
pDoc->ysjpfkd[2]=spfk.m_ysj3pD;
pDoc->ysjsfka[0]=spfk.m_ysj1sA;
pDoc->ysjsfka[1]=spfk.m_ysj2sA;
pDoc->ysjsfka[2]=spfk.m_ysj3sA;
pDoc->ysjsfkd[0]=spfk.m_ysj1sD;
pDoc->ysjsfkd[1]=spfk.m_ysj2sD;
pDoc->ysjsfkd[2]=spfk.m_ysj3sD;
pDoc->ylpfk[0]=spfk.m_ylpfk1;
pDoc->ylpfk[1]=spfk.m_ylpfk2;
pDoc->ylpfk[2]=spfk.m_ylpfk3;
pDoc->ylsfk[0]=spfk.m_ylsfk1;
pDoc->ylsfk[1]=spfk.m_ylsfk2;
pDoc->ylsfk[2]=spfk.m_ylsfk3;
pDoc->pfkv=spfk.m_pfkv;
pDoc->sfkv=spfk.m_sfkv;
}
} 展开
2个回答
展开全部
UpdateData(true);
pDoc->spfasj=spfk.m_spfasj;
pDoc->zsjpfka[0]=spfk.m_zsj1pA;
pDoc->zsjpfka[1]=spfk.m_zsj2pA;
...
...
UpdateData(false);
^=^ o(∩_∩)o
UpdateData(true);//把绑定更新到变量
UpdateData(false);//把变量更新到绑定
比如你在一个文本框上绑定了一个m_member变量,用UpdateData(false);即可把这个值在文本框里显示出来,反之,UpdateData(true);能把填入文本框的内容赋值给m_member
pDoc->spfasj=spfk.m_spfasj;
pDoc->zsjpfka[0]=spfk.m_zsj1pA;
pDoc->zsjpfka[1]=spfk.m_zsj2pA;
...
...
UpdateData(false);
^=^ o(∩_∩)o
UpdateData(true);//把绑定更新到变量
UpdateData(false);//把变量更新到绑定
比如你在一个文本框上绑定了一个m_member变量,用UpdateData(false);即可把这个值在文本框里显示出来,反之,UpdateData(true);能把填入文本框的内容赋值给m_member
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询