基于主dialog程序,dialog中有放一button, spin1在其他一个dialog1中,spin2在另一个dialog2中,要求button触发dialog1(或dialog2),spin1(或spin2)能够微调,
问题:
在哪儿设置SetRange(),我在Onbutton()中失败!有没有其他什么方法.
问题:
在哪儿设置SetRange(),我在Onbutton()中失败!有没有其他什么方法.
解决方案 »
- 各位大虾帮帮忙哦!在PC上用VC与串行设备(例如变频器,PLC)通讯如何编程啊?不胜感激!
- 怎样把图片缩放到指定大小,按比例的,有计算公式的,谢谢了
- 新线程没有立即运行
- 内存映射文件时能不能动态指定物理存储器的大小?
- 我想在向量(或其它类似的数据结构)中存储不通类型的元素该怎么做?
- 怎么得到行呢???
- 初学VC/MFC的郁闷——请各位高手介绍点经验啊!! 急!!谢谢!!!
- 哪位有Rational Rose Enterprise 的installing Key.
- 请教hook问题。。。。。。
- DriverStudio 2.01版正式版的序列号?
- 麻烦高手给我看一下,应该不难的,解决即结帖(很急!)
- 如何在对话框中实现注销功能?
void CGameDlg::OnPost()
{
CDialog2 dlg;
dlg.m_Spin.SetRange32(0,100000);//m_Spin是CDilog2中的变量
//CSpinButtonCtrl m_Spin;
}
// CMyDialog dialog
CMyDialog::CMyDialog(CWnd* pParent /*=NULL*/)
: CDialog(CMyDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CMyDialog)
m_hour = 0;
m_minu = 0;
m_pWnd = NULL;
m_someint = 0;
m_isSpin = FALSE;
//}}AFX_DATA_INIT
}
void CMyDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMyDialog)
DDX_Control(pDX, IDC_SPIN2, m_mySpinCtrl2);
DDX_Control(pDX, IDC_SPIN1, m_mySpinCtrl);
DDX_Text(pDX, IDC_EDIT1, m_hour);
DDX_Text(pDX, IDC_EDIT2, m_minu);
DDX_Text(pDX, IDC_EDIT3, m_someint);
DDV_MinMaxInt(pDX, m_someint, 0, 10);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMyDialog, CDialog)
//{{AFX_MSG_MAP(CMyDialog)
ON_EN_SETFOCUS(IDC_EDIT1, OnSetfocusEdit1)
ON_EN_SETFOCUS(IDC_EDIT2, OnSetfocusEdit2)
ON_EN_KILLFOCUS(IDC_EDIT1, OnKillfocusEdit1)
ON_EN_KILLFOCUS(IDC_EDIT2, OnKillfocusEdit2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
// CMyDialog message handlersvoid CMyDialog::OnOK()
{
// TODO: Add extra validation here CDialog::OnOK();
}BOOL CMyDialog::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
((CSpinButtonCtrl*)GetDlgItem(IDC_SPIN2))->SetRange(0,100);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CMyDialog::OnSetfocusEdit1()
{
// TODO: Add your control notification handler code here
GetDlgItem(IDC_SPIN1)->EnableWindow(TRUE);
m_pWnd = GetFocus();
m_mySpinCtrl.SetBuddy(m_pWnd);
m_mySpinCtrl.SetRange(0,23);
// GetDlgItem(IDC_SPIN1)->EnableWindow(FALSE);
}void CMyDialog::OnSetfocusEdit2()
{
// TODO: Add your control notification handler code here
GetDlgItem(IDC_SPIN1)->EnableWindow(TRUE);
m_pWnd = GetFocus();
m_mySpinCtrl.SetBuddy(m_pWnd);
m_mySpinCtrl.SetRange(0,59);
// GetDlgItem(IDC_SPIN1)->EnableWindow(FALSE);
}void CMyDialog::OnKillfocusEdit1()
{
// TODO: Add your control notification handler code here
GetDlgItem(IDC_SPIN1)->EnableWindow(FALSE);
}void CMyDialog::OnKillfocusEdit2()
{
// TODO: Add your control notification handler code here
GetDlgItem(IDC_SPIN1)->EnableWindow(FALSE);
}
m_Spin.SetRange32(0,100000);
应该在CDialog2添加两个成员变量:int m_low, m_up;然后在OnPost()中:
CDialog2 dlg;
dlg.m_low = 0;
dlg.m_up = 100000;
在CDialog2::OnInitDialgo()中:(此时其成员控件变量m_Spin是有效的了,并且m_low和m_up由调用的程序赋值)
m_Spin.SetRange32(m_low, m_up);