]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/control.cpp
wxChoice and wxListBox GTK+ changes (wxChoice works, wxListBox still doesn't)
[wxWidgets.git] / src / msw / control.cpp
index 7f609f7bd6b00841a116122225fa38a01e81a4a3..f610c69d779cb287a8b50e8ccd87b96c5ddda72a 100644 (file)
@@ -30,7 +30,7 @@
 
 #include "wx/msw/private.h"
 
-#if (defined(__WIN95__) && !defined(__GNUWIN32__)) || defined(__TWIN32__)
+#if (defined(__WIN95__) && !defined(__GNUWIN32__)) || defined(__TWIN32__) || defined(wxUSE_NORLANDER_HEADERS)
 #include <commctrl.h>
 #endif
 
@@ -58,6 +58,44 @@ wxControl::~wxControl()
     m_isBeingDeleted = TRUE;
 }
 
+bool wxControl::MSWCreateControl(const wxChar *classname, WXDWORD style)
+{
+    m_hWnd = (WXHWND)::CreateWindowEx
+                       (
+                        GetExStyle(style),  // extended style
+                        classname,          // the kind of control to create
+                        NULL,               // the window name
+                        style,              // the window style
+                        0, 0, 0, 0,         // the window position and size
+                        GetHwndOf(GetParent()),  // parent
+                        (HMENU)GetId(),     // child id
+                        wxGetInstance(),    // app instance
+                        NULL                // creation parameters
+                       );
+
+    if ( !m_hWnd )
+    {
+#ifdef __WXDEBUG__
+        wxLogError(wxT("Failed to create a control of class '%s'"), classname);
+#endif // DEBUG
+
+        return FALSE;
+    }
+
+    // subclass again for purposes of dialog editing mode
+    SubclassWin(m_hWnd);
+
+    // controls use the same font and colours as their parent dialog by default
+    InheritAttributes();
+
+    return TRUE;
+}
+
+wxSize wxControl::DoGetBestSize()
+{
+    return wxSize(DEFAULT_ITEM_WIDTH, DEFAULT_ITEM_HEIGHT);
+}
+
 bool wxControl::ProcessCommand(wxCommandEvent& event)
 {
 #if WXWIN_COMPATIBILITY
@@ -142,6 +180,19 @@ void wxControl::OnEraseBackground(wxEraseEvent& event)
     ::SetMapMode((HDC) event.GetDC()->GetHDC(), mode);
 }
 
+WXDWORD wxControl::GetExStyle(WXDWORD& style) const
+{
+    bool want3D;
+    WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D) ;
+
+    // Even with extended styles, need to combine with WS_BORDER
+    // for them to look right.
+    if ( want3D || wxStyleHasBorder(m_windowStyle) )
+        style |= WS_BORDER;
+
+    return exStyle;
+}
+
 // ---------------------------------------------------------------------------
 // global functions
 // ---------------------------------------------------------------------------