编辑控件未使用旋转控件 MFC 进行更新
我正在尝试使用 MFC Visual Studio .net 2003 来使用编辑控件和旋转控件。我已经对旋转控件进行了基本设置,例如设置“AutoBuddy”属性和“ >SetBuddyInteger”属性设置为 True,以便 Spin 控件与其旁边的编辑控件协调工作。在 Spin 控件的事件处理程序中,当我尝试调用 Invalidate() 函数时遇到问题。我的编辑控件中的浮点值不会更新并保持为零。如果我删除 Invalidate(),则值会增加,但我的绘制函数显然不会更新。下面给出了以下代码:
void CMyDlg::OnSpinA(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
// TODO: Add your control notification handler code here
UpdateData();
m_A = m_ASpinCtrl.GetPos(); // m_A is my edit control float value variable
Invalidate(); // Invalidate is to be called to update my paint function to redraw the drawing
UpdateData(false);
*pResult = 0;
}
我也为两个控件正确执行了 Tab 键顺序。
对我哪里出错有什么建议吗?
提前致谢。
I am trying to use an edit control along with a spin control using MFC visual studio .net 2003. I have carried out the basic settings for the spin control like setting the "AutoBuddy" property and "SetBuddyInteger" property to True so that the Spin control works in coordination with the edit control next to it. In my Spin control's event handler, I am facing a problem when I am trying to call my Invalidate() function. The float value in my edit control does not update and stays zero. If I remove the Invalidate(), then the value increments but my paint function is not updated obviously. A code of the following is given below:
void CMyDlg::OnSpinA(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
// TODO: Add your control notification handler code here
UpdateData();
m_A = m_ASpinCtrl.GetPos(); // m_A is my edit control float value variable
Invalidate(); // Invalidate is to be called to update my paint function to redraw the drawing
UpdateData(false);
*pResult = 0;
}
I have carried out the tab order correctly as well for the two controls.
Any suggestions on where I am going wrong?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您只想拥有一个旋转整数,则不必覆盖任何内容。
旋转控件必须位于 Tab 键顺序中编辑控件的旁边。有了AutoBuddy,这就是您所要做的一切。
If you just want to have a spinning integer, you don't have to override anything.
The spin control has to be right next to the edit control in the tab order. With AutoBuddy that's all you have to do.
m_A 当取回位置时会做一些奇怪的事情并且不会返回正确的值。尝试使用指针获取您的位置和值,然后执行 invalidate()。
这应该工作得很好。如果您仍然遇到任何问题,请告诉我。
m_A when getting the position back would do something weird and would not return you the correct value. Try using the pointer to get your position and value and then carry out the invalidate().
This should work perfectly well. Let me know if you still get any problems.