#include "wx/spinctrl.h"
#include "wx/msw/private.h"
-#if defined(__WIN95__) && !(defined(__GNUWIN32_OLD__) || defined(__TWIN32__))
+#if defined(__WIN95__) && !((defined(__GNUWIN32_OLD__) || defined(__TWIN32__)) && !defined(__CYGWIN10__))
#include <commctrl.h>
#endif
{
wxSpinCtrl *spin = (wxSpinCtrl *)::GetWindowLong(hwnd, GWL_USERDATA);
- // forward some messages (the key ones only so far) to the spin ctrl
+ // forward some messages (the key and focus ones only so far) to
+ // the spin ctrl
switch ( message )
{
+ case WM_SETFOCUS:
+ case WM_KILLFOCUS:
case WM_CHAR:
case WM_DEADCHAR:
case WM_KEYUP:
if (!(::IsWindow(hwnd) && ((wxSpinCtrl *)::GetWindowLong(hwnd, GWL_USERDATA)) == spin))
return 0;
break;
+
+ case WM_GETDLGCODE:
+ // we want to get WXK_RETURN in order to generate the event for it
+ return DLGC_WANTCHARS;
}
+
return ::CallWindowProc(CASTWNDPROC spin->GetBuddyWndProc(),
hwnd, message, wParam, lParam);
}
// know whether this is a horizontal or vertical control (we're always
// vertical)
style |= wxSP_VERTICAL;
+
+ if ( (style & wxBORDER_MASK) == wxBORDER_DEFAULT )
+ style |= wxBORDER_SUNKEN;
+
SetWindowStyle(style);
// calculate the sizes: the size given is the toal size for both controls
if ( style & wxCLIP_SIBLINGS )
msStyle |= WS_CLIPSIBLINGS;
- // we want to get WXK_RETURN in order to generate the event for it
- m_lDlgCode = DLGC_WANTCHARS;
-
// create the text window
m_hwndBuddy = (WXHWND)::CreateWindowEx
(
{
ms_allSpins.Remove(this);
+ // This removes spurious memory leak reporting
+ if (ms_allSpins.GetCount() == 0)
+ ms_allSpins.Clear();
+
// destroy the buddy window because this pointer which wxBuddyTextWndProc
// uses will not soon be valid any more
::DestroyWindow(GetBuddyHwnd());
return n;
}
+void wxSpinCtrl::SetSelection(long from, long to)
+{
+ // if from and to are both -1, it means (in wxWindows) that all text should
+ // be selected - translate into Windows convention
+ if ( (from == -1) && (to == -1) )
+ {
+ from = 0;
+ }
+
+ ::SendMessage((HWND)m_hwndBuddy, EM_SETSEL, (WPARAM)from, (LPARAM)to);
+}
+
// ----------------------------------------------------------------------------
// forward some methods to subcontrols
// ----------------------------------------------------------------------------