Skip to content

Commit

Permalink
修正combo滚动条处理的一处bug
Browse files Browse the repository at this point in the history
  • Loading branch information
wangchyz committed Mar 23, 2016
1 parent 61247ad commit 3fa8930
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
20 changes: 18 additions & 2 deletions DuiLib/Control/UICombo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ class CComboWnd : public CWindowWnd
CComboUI* m_pOwner;
CVerticalLayoutUI* m_pLayout;
int m_iOldSel;
bool m_bScrollbarClicked;
};


Expand All @@ -147,6 +148,7 @@ void CComboWnd::Init(CComboUI* pOwner)
m_pOwner = pOwner;
m_pLayout = NULL;
m_iOldSel = m_pOwner->GetCurSel();
m_bScrollbarClicked = false;

// Position the popup window in absolute space
SIZE szDrop = m_pOwner->GetDropBoxSize();
Expand Down Expand Up @@ -237,12 +239,26 @@ LRESULT CComboWnd::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
else m_pOwner->SetPos(m_pOwner->GetRelativePos(), false);
m_pOwner->SetFocus();
}
else if( uMsg == WM_LBUTTONUP ) {
else if( uMsg == WM_LBUTTONDOWN || uMsg == WM_LBUTTONDBLCLK ) {
POINT pt = { 0 };
::GetCursorPos(&pt);
::ScreenToClient(m_pm.GetPaintWindow(), &pt);
CControlUI* pControl = m_pm.FindControl(pt);
if( pControl && _tcscmp(pControl->GetClass(), DUI_CTR_SCROLLBAR) != 0 ) PostMessage(WM_KILLFOCUS);
if( pControl && _tcscmp(pControl->GetClass(), DUI_CTR_SCROLLBAR) == 0 ) {
m_bScrollbarClicked = true;
}
}
else if( uMsg == WM_LBUTTONUP ) {
if (m_bScrollbarClicked) {
m_bScrollbarClicked = false;
}
else {
POINT pt = { 0 };
::GetCursorPos(&pt);
::ScreenToClient(m_pm.GetPaintWindow(), &pt);
CControlUI* pControl = m_pm.FindControl(pt);
if( pControl && _tcscmp(pControl->GetClass(), DUI_CTR_SCROLLBAR) != 0 ) PostMessage(WM_KILLFOCUS);
}
}
else if( uMsg == WM_KEYDOWN ) {
switch( wParam ) {
Expand Down
4 changes: 2 additions & 2 deletions bin/test1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
<RichEdit name="testrichedit1" bordercolor="#FF0000" bordersize="2" borderround="8,8" inset="4,2,4,2" bkcolor="#FFE2E5EA" bkcolor2="#FF00F5DA" bkcolor3="#FFF2F5FA" font="1" multiline="false" rich="false" hscrollbar="true" autohscroll="true"/>
<DateTime name="DateTime" width="200" height="30" bkcolor="#FFE2E5EA" padding="0,5,0,0" />
<CheckBox name="CheckBox1" width="20" height="20" bkcolor="#FFEA679F" />
<ComboBox name="ComboBox1" width="200" height="30" bkcolor="#FFEA679F" >
<ComboBox name="ComboBox1" width="200" height="30" bkcolor="#FFEA679F" bordersize="1" bordercolor="0xFFFF0000">
<ListLabelElement text="11111111111111"/>
<ListLabelElement text="22222222222222"/>
<ListLabelElement text="33333333333333"/>
<ListLabelElement text="33333333333333" selected="true"/>
<ListLabelElement text="44444444444444"/>
<ListLabelElement text="55555555555555"/>
<ComboBox height="30" bkcolor="#FF00679F" >
Expand Down

0 comments on commit 3fa8930

Please sign in to comment.