关于combobox控件的问题,急,请大虾帮忙。
我的程序中,界面里有一个combobox控件,设置其owner draw属性为no,希望它有word中显示比例选择框的功能,我派生了一个CComboBox类函数如下
BOOL CCustomComboBox::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if (pMsg->message==WM_KEYDOWN)
{
if (pMsg->wParam==VK_RETURN)
{// 处理回车键
CString str;
int scale;
this->GetWindowText(str);
scale=atoi(str);
if((!IsInputAllNumber(str))||scale==0)
{
MessageBox("度量单位无效!","输入错",MB_ICONHAND);
str.Format("×%d",iImageScale);
this->SetWindowText(str);
SetFocus();
return CComboBox::PreTranslateMessage(pMsg);
}
else
iImageScale=scale;
str="×"+str;
this->SetWindowText(str);
SetFocus();
}
}
return CComboBox::PreTranslateMessage(pMsg);
}
该combobox的list中的内容为
×1
×10
×20
×30
×40
×100
以上六项。
当我在combobox中输入2并按回车后,combobox的显示可以转换为×2,但当鼠标左键点击combobox右边的按钮时,其显示立刻变为×20,(输入为2、3、4时均会出现该bug但其他数值不会)。请问这是什么原因?望各位大虾指教。