moved code working around combobox selection bug to wxComboBox: wxChoice doesn't have selection anyhow, why should it be there?
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31540 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
04049dbb0b
commit
51cdee11e0
@ -136,6 +136,9 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
|
virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
|
||||||
|
virtual void DoSetSize(int x, int y,
|
||||||
|
int width, int height,
|
||||||
|
int sizeFlags = wxSIZE_AUTO);
|
||||||
|
|
||||||
// common part of all ctors
|
// common part of all ctors
|
||||||
void Init() { m_selectionOld = -1; }
|
void Init() { m_selectionOld = -1; }
|
||||||
|
@ -505,24 +505,8 @@ void wxChoice::DoSetSize(int x, int y,
|
|||||||
height += hItem*(nItems + 1);
|
height += hItem*(nItems + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// To work around a Windows bug (see "Bug in Windows Combobox" thread in Google Groups)
|
|
||||||
// we have to reset the selection if it was accidentally selected in the size.
|
|
||||||
DWORD oldSelStart = 0;
|
|
||||||
DWORD oldSelEnd = 0;
|
|
||||||
DWORD newSelStart = 0;
|
|
||||||
DWORD newSelEnd = 0;
|
|
||||||
|
|
||||||
::SendMessage(GetHwnd(), CB_GETEDITSEL, (WPARAM) & oldSelStart, (LPARAM) & oldSelEnd);
|
|
||||||
|
|
||||||
wxControl::DoSetSize(x, y, width, height, sizeFlags);
|
wxControl::DoSetSize(x, y, width, height, sizeFlags);
|
||||||
|
|
||||||
::SendMessage(GetHwnd(), CB_GETEDITSEL, (WPARAM) & newSelStart, (LPARAM) & newSelEnd);
|
|
||||||
|
|
||||||
if (oldSelStart != newSelStart || oldSelEnd != newSelEnd)
|
|
||||||
{
|
|
||||||
::SendMessage(GetHwnd(), CB_SETEDITSEL, (WPARAM) 0, (LPARAM) MAKELPARAM(oldSelStart, oldSelEnd));
|
|
||||||
}
|
|
||||||
|
|
||||||
// I'm commenting this out since the code appears to make choices
|
// I'm commenting this out since the code appears to make choices
|
||||||
// and comboxes too high when they have associated sizers. I'm sure this
|
// and comboxes too high when they have associated sizers. I'm sure this
|
||||||
// is not the end of the story, which is why I'm leaving it #if'ed out for
|
// is not the end of the story, which is why I'm leaving it #if'ed out for
|
||||||
|
@ -476,6 +476,29 @@ WXDWORD wxComboBox::MSWGetStyle(long style, WXDWORD *exstyle) const
|
|||||||
return msStyle;
|
return msStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxComboBox geometry
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void
|
||||||
|
wxComboBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||||
|
{
|
||||||
|
// work around a Windows bug (search for "Bug in Windows Combobox" in
|
||||||
|
// Google Groups): resizing the combobox changes the selection in it
|
||||||
|
long fromOld, toOld;
|
||||||
|
GetSelection(&fromOld, &toOld);
|
||||||
|
|
||||||
|
wxChoice::DoSetSize(x, y, width, height, sizeFlags);
|
||||||
|
|
||||||
|
long fromNew, toNew;
|
||||||
|
GetSelection(&fromNew, &toNew);
|
||||||
|
|
||||||
|
if ( fromOld != fromNew || toOld != toNew )
|
||||||
|
{
|
||||||
|
SetSelection(fromOld, toOld);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxComboBox text control-like methods
|
// wxComboBox text control-like methods
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user