]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/control.cpp
added default style wxFRAME_TOOL_WINDOW to creation
[wxWidgets.git] / src / msw / control.cpp
index fd82221246087afa56984d9b2a196b6826d40218..5454e029f9e633219be6bbfe51221104fdbb93c5 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        control.cpp
+// Name:        msw/control.cpp
 // Purpose:     wxControl class
 // Author:      Julian Smart
 // Modified by:
 /////////////////////////////////////////////////////////////////////////////
 
 #ifdef __GNUG__
-#pragma implementation "control.h"
+    #pragma implementation "control.h"
 #endif
 
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
 #ifdef __BORLANDC__
-#pragma hdrstop
+    #pragma hdrstop
 #endif
 
+#if wxUSE_CONTROLS
+
 #ifndef WX_PRECOMP
-#include "wx/event.h"
-#include "wx/app.h"
-#include "wx/dcclient.h"
-#include "wx/log.h"
+    #include "wx/event.h"
+    #include "wx/app.h"
+    #include "wx/dcclient.h"
+    #include "wx/log.h"
 #endif
 
 #include "wx/control.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
 
@@ -44,9 +46,6 @@ END_EVENT_TABLE()
 // Item members
 wxControl::wxControl()
 {
-    m_backgroundColour = *wxWHITE;
-    m_foregroundColour = *wxBLACK;
-
 #if WXWIN_COMPATIBILITY
     m_callback = 0;
 #endif // WXWIN_COMPATIBILITY
@@ -96,14 +95,18 @@ bool wxControl::MSWCreateControl(const wxChar *classname,
     // by default)
     style |= WS_CHILD | WS_VISIBLE;
 
+    int x = pos.x == -1 ? 0 : pos.x,
+        y = pos.y == -1 ? 0 : pos.y,
+        w = size.x == -1 ? 0 : size.x,
+        h = size.y == -1 ? 0 : size.y;
+
     m_hWnd = (WXHWND)::CreateWindowEx
                        (
                         exstyle,            // extended style
                         classname,          // the kind of control to create
                         label,              // the window name
                         style,              // the window style
-                        pos.x, pos.y,       // the window position
-                        size.x, size.y,     //            and size
+                        x, y, w, h,         // the window position and size
                         GetHwndOf(GetParent()),  // parent
                         (HMENU)GetId(),     // child id
                         wxGetInstance(),    // app instance
@@ -126,12 +129,18 @@ bool wxControl::MSWCreateControl(const wxChar *classname,
     }
 #endif // wxUSE_CTL3D
 
-    // subclass again for purposes of dialog editing mode
+    // install wxWindows window proc for this window
     SubclassWin(m_hWnd);
 
     // controls use the same font and colours as their parent dialog by default
     InheritAttributes();
 
+    // set the size now if no initial size specified
+    if ( w == 0 || h == 0 )
+    {
+        SetBestSize(size);
+    }
+
     return TRUE;
 }
 
@@ -160,10 +169,10 @@ bool wxControl::MSWOnNotify(int idCtrl,
                             WXLPARAM lParam,
                             WXLPARAM* result)
 {
-    wxCommandEvent event(wxEVT_NULL, m_windowId);
     wxEventType eventType = wxEVT_NULL;
-    NMHDR *hdr1 = (NMHDR*) lParam;
-    switch ( hdr1->code )
+
+    NMHDR *hdr = (NMHDR*) lParam;
+    switch ( hdr->code )
     {
         case NM_CLICK:
             eventType = wxEVT_COMMAND_LEFT_CLICK;
@@ -197,6 +206,7 @@ bool wxControl::MSWOnNotify(int idCtrl,
             return wxWindow::MSWOnNotify(idCtrl, lParam, result);
     }
 
+    wxCommandEvent event(wxEVT_NULL, m_windowId);
     event.SetEventType(eventType);
     event.SetEventObject(this);
 
@@ -224,9 +234,16 @@ void wxControl::OnEraseBackground(wxEraseEvent& event)
 }
 
 WXHBRUSH wxControl::OnCtlColor(WXHDC pDC, WXHWND WXUNUSED(pWnd), WXUINT WXUNUSED(nCtlColor),
+#if wxUSE_CTL3D
+                               WXUINT message,
+                               WXWPARAM wParam,
+                               WXLPARAM lParam
+#else
                                WXUINT WXUNUSED(message),
                                WXWPARAM WXUNUSED(wParam),
-                               WXLPARAM WXUNUSED(lParam))
+                               WXLPARAM WXUNUSED(lParam)
+#endif
+    )
 {
 #if wxUSE_CTL3D
     if ( m_useCtl3D )
@@ -298,3 +315,4 @@ void wxFindMaxSize(WXHWND wnd, RECT *rect)
         rect->bottom = bottom;
 }
 
+#endif // wxUSE_CONTROLS