]> git.saurik.com Git - wxWidgets.git/commitdiff
Fixed spurious selection of combobox text during resize
authorJulian Smart <julian@anthemion.co.uk>
Wed, 8 Dec 2004 17:51:48 +0000 (17:51 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Wed, 8 Dec 2004 17:51:48 +0000 (17:51 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30902 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
src/msw/choice.cpp

index 261cd05d5aaeca098e9f2dd68d6ae8afe22df801..a87632042a7c2939683707669aa0367a486f091d 100644 (file)
@@ -57,6 +57,7 @@ wxMSW:
 
 - fixed enhanced metafiles loading from files (Andreas Goebel)
 - wxRadioButtons no longer have to be consecutive in a group
+- fixed spurious selection of combobox text during resize
 
 wxUniv:
 
index 362f98ccb71f7b3fad21fcad4d0289b140554f2f..95632e70576aa67eb8efd093428e8a29e8665514 100644 (file)
@@ -505,8 +505,24 @@ void wxChoice::DoSetSize(int x, int y,
         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);
 
+    ::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
     // 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