WINCE中微调按键和编辑框的绑定问题

   设计一个wince应用程序,要求有三个微调按钮和编辑框,用来调整颜色搭配。

首先我们放置三对微调按钮和编辑框,并在初始化中绑定

BOOL CSpinUseDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// 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
	CSpinButtonCtrl *pSpinRed = (CSpinButtonCtrl*)GetDlgItem(IDC_SPIN_RED);
	ASSERT(pSpinRed!=NULL);
	pSpinRed->SetBuddy(GetDlgItem(IDC_EDT_RED));
	pSpinRed->SetRange(0,255);
	pSpinRed->SetPos(128);
	CSpinButtonCtrl *pSpinGreen = (CSpinButtonCtrl*)GetDlgItem(IDC_SPIN_GREEN);
	ASSERT(pSpinGreen!=NULL);
	pSpinGreen->SetBuddy(GetDlgItem(IDC_EDT_GREEN));
	pSpinGreen->SetRange(0,255);
	pSpinGreen->SetPos(128);
	CSpinButtonCtrl *pSpinBlue = (CSpinButtonCtrl*)GetDlgItem(IDC_SPIN_BLUE);
	ASSERT(pSpinBlue!=NULL);
	pSpinBlue->SetBuddy(GetDlgItem(IDC_EDT_BLUE));
	pSpinBlue->SetRange(0,255);
	pSpinBlue->SetPos(128);
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

消息处理函数:

void CSpinUseDlg::RGBColorChange() 
{
	UpdateData(TRUE);
	CBrush colorBrush;
	COLORREF clRGB;
    clRGB = RGB(m_red,m_green,m_blue);
	CClientDC * pClientDC;
	pClientDC = new CClientDC(this);
	colorBrush.CreateSolidBrush(clRGB);
	CRect rect(80,120,160,200);
	pClientDC->FillRect(rect,&colorBrush);
	delete pClientDC;
}

void CSpinUseDlg::OnEnChangeEdtRed()
{
	RGBColorChange();
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.

	// TODO:  Add your control notification handler code here
}

void CSpinUseDlg::OnEnChangeEdtGreen()
{
	RGBColorChange();
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.

	// TODO:  Add your control notification handler code here
}

void CSpinUseDlg::OnEnChangeEdtBlue()
{
	RGBColorChange();
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.

	// TODO:  Add your control notification handler code here
}
设置三个变量,分别关联三个颜色值,范围是0-255,整数。

public:
	BYTE m_red;  //
	BYTE m_green; //
	BYTE m_blue; //


变量和编辑框的值绑定

void CSpinUseDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Text(pDX, IDC_EDT_RED, m_red);
	DDV_MinMaxByte(pDX, m_red, 0, 255);
	DDX_Text(pDX, IDC_EDT_GREEN, m_green);
	DDV_MinMaxByte(pDX, m_green, 0, 255);
	DDX_Text(pDX, IDC_EDT_BLUE, m_blue);
	DDV_MinMaxByte(pDX, m_blue, 0, 25

运行程序,发现微调按键并不能调整编辑框的值,先前的绑定语句没有起作用。

一番查找后,问题解决了,在微调按钮的属性里面需要设置Set buddy integer为ture,程序正常运行,绑定成功。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值