lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re[2]: [lmi] Deleting contents of wxSpinCtrl's edit subcontrol


From: Vadim Zeitlin
Subject: Re[2]: [lmi] Deleting contents of wxSpinCtrl's edit subcontrol
Date: Mon, 26 Jun 2006 14:19:35 +0200

On Wed, 21 Jun 2006 08:34:18 -0400 "Boutin, Wendy" <address@hidden> wrote:

BW> This remains a problem in lmi, but I find it only occurs when the 
BW> minimum value is zero. Is this something you could look into?

 Hello,

 This seems to be a bug in Windows (or "native Windows behaviour" if you
prefer): the spin button is supposed to update the contents of the spin
control but it doesn't do it if the value is 0 and the text control is
(already) empty. Apparently it considers that empty text is equivalent to 0
or something like this. Anyhow, after realizing what the problem was it was
easy to fix it and I just did this in wx cvs. If you don't want to update
at this moment you can just apply this patch:

Index: include/wx/msw/spinctrl.h
===================================================================
RCS file: /pack/cvsroots/wxwidgets/wxWindows/include/wx/msw/spinctrl.h,v
retrieving revision 1.26
diff -b -u -2 -r1.26 spinctrl.h
--- include/wx/msw/spinctrl.h   2006/01/17 16:59:02     1.26
+++ include/wx/msw/spinctrl.h   2006/06/26 12:17:22
@@ -66,5 +66,5 @@
     virtual ~wxSpinCtrl();

-    virtual void SetValue(int val) { wxSpinButton::SetValue(val); }
+    virtual void SetValue(int val);
     virtual int  GetValue() const;
     virtual bool SetFont(const wxFont &font);
Index: src/msw/spinctrl.cpp
===================================================================
RCS file: /pack/cvsroots/wxwidgets/wxWindows/src/msw/spinctrl.cpp,v
retrieving revision 1.59
diff -b -u -2 -r1.59 spinctrl.cpp
--- src/msw/spinctrl.cpp        2006/01/17 16:47:55     1.59
+++ src/msw/spinctrl.cpp        2006/06/26 12:17:22
@@ -432,4 +432,20 @@
 }

+void  wxSpinCtrl::SetValue(int val)
+{
+    wxSpinButton::SetValue(val);
+
+    // normally setting the value of the spin button is enough as it updates
+    // its buddy control automatically ...
+    if ( wxGetWindowText(m_hwndBuddy).empty() )
+    {
+        // ... but sometimes it doesn't, notably when the value is 0 and the
+        // text control is currently empty, the spin button seems to be happy
+        // to leave it like this, while we really want to always show the
+        // current value in the control, so do it manually
+        ::SetWindowText(GetBuddyHwnd(), wxString::Format(_T("%ld"), val));
+    }
+}
+
 int wxSpinCtrl::GetValue() const
 {


 Please let me know if you still have any problems after applying it.
Thanks!
VZ





reply via email to

[Prev in Thread] Current Thread [Next in Thread]