+ // basic initialization
+ InitBase();
+
+ m_windowId = (id == -1) ? NewControlId() : id;
+
+ m_backgroundColour = parent->GetBackgroundColour() ;
+ m_foregroundColour = parent->GetForegroundColour() ;
+
+ SetName(name);
+
+ int x = pos.x;
+ int y = pos.y;
+ int width = size.x;
+ int height = size.y;
+
+ m_windowStyle = style;
+
+ SetParent(parent);
+
+ // get the right size for the control
+ if ( width <= 0 || height <= 0 )
+ {
+ wxSize size = DoGetBestSize();
+ if ( width <= 0 )
+ width = size.x;
+ if ( height <= 0 )
+ height = size.y;
+ }
+
+ if ( x < 0 )
+ x = 0;
+ if ( y < 0 )
+ y = 0;
+
+ // translate the styles
+ DWORD wstyle = WS_VISIBLE | WS_CHILD | WS_TABSTOP |
+ UDS_NOTHOUSANDS | // never useful, sometimes harmful
+ UDS_SETBUDDYINT; // it doesn't harm if we don't have buddy
+
+ if ( m_windowStyle & wxSP_HORIZONTAL )
+ wstyle |= UDS_HORZ;
+ if ( m_windowStyle & wxSP_ARROW_KEYS )
+ wstyle |= UDS_ARROWKEYS;
+ if ( m_windowStyle & wxSP_WRAP )
+ wstyle |= UDS_WRAP;
+
+ // create the UpDown control.
+ m_hWnd = (WXHWND)CreateUpDownControl
+ (
+ wstyle,
+ x, y, width, height,
+ GetHwndOf(parent),
+ m_windowId,
+ wxGetInstance(),
+ NULL, // no buddy
+ m_max, m_min,
+ m_min // initial position
+ );
+
+ if ( !m_hWnd )
+ {
+ wxLogLastError("CreateUpDownControl");
+
+ return FALSE;
+ }
+
+ if ( parent )
+ {
+ parent->AddChild(this);
+ }
+
+ SubclassWin(m_hWnd);
+
+ return TRUE;