]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/statline.cpp
Check for NULL before dereferencing
[wxWidgets.git] / src / msw / statline.cpp
index 2bf14042af379e9fe41b3e5bdcb51d9306abab97..088e4e2d39727bf66fdaa04680970276e0597cb1 100644 (file)
@@ -52,48 +52,31 @@ IMPLEMENT_DYNAMIC_CLASS(wxStaticLine, wxControl)
 // wxStaticLine
 // ----------------------------------------------------------------------------
 
-bool wxStaticLine::Create( wxWindow *parent,
-                           wxWindowID id,
-                           const wxPoint &pos,
-                           const wxSize &size,
-                           long style,
-                           const wxString &name)
+bool wxStaticLine::Create(wxWindow *parent,
+                          wxWindowID id,
+                          const wxPoint& pos,
+                          const wxSize& sizeOrig,
+                          long style,
+                          const wxString &name)
 {
-    if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) )
-        return FALSE;
-
-    parent->AddChild(this);
-
-    wxSize sizeReal = AdjustSize(size);
-
-    DWORD wstyle = WS_CHILD | WS_VISIBLE | SS_GRAYRECT | SS_SUNKEN | SS_NOTIFY;
-
-    if ( style & wxCLIP_SIBLINGS )
-        wstyle |= WS_CLIPSIBLINGS;
+    wxSize size = AdjustSize(sizeOrig);
 
+    if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) )
+        return FALSE;
 
-    m_hWnd = (WXHWND)::CreateWindow
-                       (
-                        wxT("STATIC"),
-                        wxT(""),
-                        wstyle,
-                        pos.x, pos.y, sizeReal.x, sizeReal.y,
-                        GetWinHwnd(parent),
-                        (HMENU)m_windowId,
-                        wxGetInstance(),
-                        NULL
-                       );
-
-    if ( !m_hWnd )
-    {
-        wxLogDebug(wxT("Failed to create static control"));
+    return MSWCreateControl(_T("STATIC"), _T(""), pos, size, style);
+}
 
-        return FALSE;
-    }
+WXDWORD wxStaticLine::MSWGetStyle(long style, WXDWORD *exstyle) const
+{
+    // we never have border
+    style &= ~wxBORDER_MASK;
+    style |= wxBORDER_NONE;
 
-    SubclassWin(m_hWnd);
+    WXDWORD msStyle = wxControl::MSWGetStyle(style, exstyle);
 
-    return TRUE;
+    // add our default styles
+    return msStyle | SS_GRAYRECT | SS_SUNKEN | SS_NOTIFY | WS_CLIPSIBLINGS;
 }
 
 #endif // wxUSE_STATLINE