duilib CComboUI 有时鼠标拖动不准 by lssaint
次bug修复比较简单,但比较难找到原因先贴源码:
在 CComboWnd中找到HandleMessage方法。
将
if( uMsg == WM_KEYDOWN ) {
switch( wParam ) {
case VK_ESCAPE:
m_pOwner->SelectItem(m_iOldSel, true);
EnsureVisible(m_iOldSel);
// FALL THROUGH...
case VK_RETURN:
PostMessage(WM_KILLFOCUS);
break;
default:
TEventUI event;
event.Type = UIEVENT_KEYDOWN;
event.chKey = (TCHAR)wParam;
m_pOwner->DoEvent(event);
EnsureVisible(m_pOwner->GetCurSel());
return 0;
}
}
修改为
if( uMsg == WM_KEYDOWN ) {
switch( wParam ) {
case VK_ESCAPE:
m_pOwner->SelectItem(m_iOldSel, true);
EnsureVisible(m_iOldSel);
// FALL THROUGH...
case VK_RETURN:
PostMessage(WM_KILLFOCUS);
break;
default:
TEventUI event;
event.Type = UIEVENT_KEYDOWN;
event.chKey = (TCHAR)wParam;
m_pOwner->DoEvent(event);
if(wParam!=17) //修改处
EnsureVisible(m_pOwner->GetCurSel());
return 0;
}
}
以下部分为转载 http://blog.csdn.net/zhuhongshu/article/details/43484589
duilib 修复combo控件打开下拉菜单后不会自动定位到上次选择的位置上的bug by Redrain
1、给CComboWnd类继承INotifyUI接口
class CComboWnd : public CWindowWnd,public INotifyUI
2、在WM_CREATE消息里,把CComboWnd添加到消息队列:
m_pm.AddNotifier(this);
3、为CComboWnd类添加 void Notify(TNotifyUI& msg) ; 成员函数
void CComboWnd::Notify(TNotifyUI& msg)
{
if (msg.sType == _T("windowinit"))
{
EnsureVisible(m_iOldSel);
}
}