]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/window.cpp
Removed some warnings in widgets sample
[wxWidgets.git] / src / msw / window.cpp
index abdcc7dac160cf78ba010f5a96d22b91d637bbcf..6099e4e34d0cce6a44571335ac7fa73018c33870 100644 (file)
@@ -29,8 +29,7 @@
 #endif
 
 #ifndef WX_PRECOMP
-    #include <windows.h>
-    #include "wx/msw/winundef.h"
+    #include "wx/msw/wrapwin.h"
     #include "wx/window.h"
     #include "wx/accel.h"
     #include "wx/setup.h"
@@ -230,7 +229,25 @@ static inline void wxBringWindowToTop(HWND hwnd)
 #ifdef __WXUNIVERSAL__
     IMPLEMENT_ABSTRACT_CLASS(wxWindowMSW, wxWindowBase)
 #else // __WXMSW__
+#if wxUSE_EXTENDED_RTTI
+IMPLEMENT_DYNAMIC_CLASS_XTI(wxWindow, wxWindowBase,"wx/window.h")
+
+WX_BEGIN_PROPERTIES_TABLE(wxWindow)
+       WX_READONLY_PROPERTY( Parent,wxWindow*, GetParent,  )
+       WX_PROPERTY( Id,wxWindowID, SetId, GetId, -1 )
+       WX_PROPERTY_SET_BY_REF( Title,wxString, SetTitle, GetTitle, wxT("") )
+       WX_PROPERTY_SET_BY_REF( Label,wxString, SetLabel, GetLabel, wxT("") )
+       WX_PROPERTY_SET_BY_REF( Position,wxPoint, SetPosition , GetPosition, wxDefaultPosition )
+       WX_PROPERTY_SET_BY_REF( Size,wxSize, SetSize, GetSize, wxDefaultSize )
+WX_END_PROPERTIES_TABLE()
+
+WX_BEGIN_HANDLERS_TABLE(wxWindow)
+WX_END_HANDLERS_TABLE()
+
+WX_CONSTRUCTOR_DUMMY(wxWindow)
+#else
     IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase)
+#endif
 #endif // __WXUNIVERSAL__/__WXMSW__
 
 BEGIN_EVENT_TABLE(wxWindowMSW, wxWindowBase)
@@ -748,13 +765,15 @@ inline int GetScrollPosition(HWND hWnd, int wOrient)
 #ifdef __WXMICROWIN__
     return ::GetScrollPosWX(hWnd, wOrient);
 #else
-    SCROLLINFO scrollInfo;
+    WinStruct<SCROLLINFO> scrollInfo;
+    scrollInfo.cbSize = sizeof(SCROLLINFO);
     scrollInfo.fMask = SIF_POS;
     if ( !::GetScrollInfo(hWnd,
-                                  wOrient,
-                                  &scrollInfo) )
+                          wOrient,
+                          &scrollInfo) )
     {
-        wxLogLastError(_T("GetScrollInfo"));
+        // Not neccessarily an error, if there are no scrollbars yet.
+        // wxLogLastError(_T("GetScrollInfo"));
     }
     return scrollInfo.nPos;
 //    return ::GetScrollPos(hWnd, wOrient);
@@ -781,13 +800,15 @@ int wxWindowMSW::GetScrollRange(int orient) const
     ::GetScrollRange(hWnd, orient == wxHORIZONTAL ? SB_HORZ : SB_VERT,
                      &minPos, &maxPos);
 #endif
-    SCROLLINFO scrollInfo;
+    WinStruct<SCROLLINFO> scrollInfo;
     scrollInfo.fMask = SIF_RANGE;
     if ( !::GetScrollInfo(hWnd,
-                                  orient == wxHORIZONTAL ? SB_HORZ : SB_VERT,
-                                  &scrollInfo) )
+                          orient == wxHORIZONTAL ? SB_HORZ : SB_VERT,
+                          &scrollInfo) )
     {
-        wxLogLastError(_T("GetScrollInfo"));
+        // Most of the time this is not really an error, since the return
+        // value can also be zero when there is no scrollbar yet.
+        // wxLogLastError(_T("GetScrollInfo"));
     }
     maxPos = scrollInfo.nMax;
 
@@ -931,7 +952,7 @@ void wxWindowMSW::SubclassWin(WXHWND hWnd)
 
     // we don't need to subclass the window of our own class (in the Windows
     // sense of the word)
-    if ( !wxCheckWindowWndProc(hWnd, (WXFARPROC)wxWndProc) )
+       if ( !wxCheckWindowWndProc(hWnd, (WXFARPROC)wxWndProc) )
     {
         ::SetWindowLong(hwnd, GWL_WNDPROC, (LONG) wxWndProc);
     }
@@ -977,6 +998,28 @@ bool wxCheckWindowWndProc(WXHWND hWnd, WXFARPROC wndProc)
     // unicows.dll, we can override unicows hooks by setting
     // Unicows_{Set,Get}WindowLong and Unicows_RegisterClass to our own
     // versions that keep track of fake<->real wnd proc mapping.
+
+       // On WinCE (at least), the wndproc comparison doesn't work,
+       // so have to use something like this.
+#ifdef __WXWINCE__
+       extern const wxChar *wxCanvasClassName;
+       extern const wxChar *wxCanvasClassNameNR;
+       extern const wxChar *wxMDIFrameClassName;
+       extern const wxChar *wxMDIFrameClassNameNoRedraw;
+       extern const wxChar *wxMDIChildFrameClassName;
+       extern const wxChar *wxMDIChildFrameClassNameNoRedraw;
+       wxString str(wxGetWindowClass(hWnd));
+       if (str == wxCanvasClassName ||
+               str == wxCanvasClassNameNR ||
+               str == wxMDIFrameClassName ||
+               str == wxMDIFrameClassNameNoRedraw ||
+               str == wxMDIChildFrameClassName ||
+               str == wxMDIChildFrameClassNameNoRedraw ||
+               str == _T("wxTLWHiddenParent"))
+               return TRUE; // Effectively means don't subclass
+       else
+               return FALSE;
+#else
     WNDCLASS cls;
     if ( !::GetClassInfo(wxGetInstance(), wxGetWindowClass(hWnd), &cls) )
     {
@@ -986,6 +1029,7 @@ bool wxCheckWindowWndProc(WXHWND hWnd, WXFARPROC wndProc)
     }
 
     return wndProc == (WXFARPROC)cls.lpfnWndProc;
+#endif
 }
 
 // ----------------------------------------------------------------------------
@@ -1987,7 +2031,10 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg)
                       node;
                       node = node->GetNext() )
                 {
-                    if ( node->GetData()->AcceptsFocus() )
+                    wxWindow * const win = node->GetData();
+                    if ( win->AcceptsFocus() &&
+                            !(::GetWindowLong(GetHwndOf(win), GWL_EXSTYLE) &
+                                WS_EX_CONTROLPARENT) )
                     {
                         // it shouldn't hang...
                         canSafelyCallIsDlgMsg = TRUE;
@@ -1996,7 +2043,7 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg)
                     }
                 }
             }
-#endif
+#endif // !__WXWINCE__
 
             if ( canSafelyCallIsDlgMsg )
             {
@@ -2300,8 +2347,17 @@ long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam
             break;
 
         case WM_PAINT:
-            processed = HandlePaint();
-            break;
+            {
+                wxPaintDCEx *pdc = 0;
+                if (wParam) {
+                    pdc = new wxPaintDCEx(this, (WXHDC) wParam);
+                }
+                processed = HandlePaint();
+                if (pdc) {
+                    delete pdc;
+                }
+                break;
+            }
 
         case WM_CLOSE:
 #ifdef __WXUNIVERSAL__
@@ -2955,18 +3011,37 @@ bool wxWindowMSW::MSWCreate(const wxChar *wclass,
     // do create the window
     wxWindowCreationHook hook(this);
 
-    m_hWnd = (WXHWND)::CreateWindowEx
-                       (
-                            extendedStyle,
-                            className,
-                            title ? title : wxEmptyString,
-                            style,
-                            x, y, w, h,
-                            (HWND)MSWGetParent(),
-                            (HMENU)controlId,
-                            wxGetInstance(),
-                            NULL                        // no extra data
-                       );
+#ifdef __WXWINCE__
+    if (extendedStyle == 0)
+    {
+        m_hWnd = (WXHWND)::CreateWindow
+            (
+            className,
+            title ? title : wxEmptyString,
+            style,
+            x, y, w, h,
+            (HWND)MSWGetParent(),
+            (HMENU)controlId,
+            wxGetInstance(),
+            NULL                        // no extra data
+            );
+    }
+    else
+#endif
+    {
+        m_hWnd = (WXHWND)::CreateWindowEx
+            (
+            extendedStyle,
+            className,
+            title ? title : wxEmptyString,
+            style,
+            x, y, w, h,
+            (HWND)MSWGetParent(),
+            (HMENU)controlId,
+            wxGetInstance(),
+            NULL                        // no extra data
+            );
+    }
 
     if ( !m_hWnd )
     {
@@ -3338,9 +3413,7 @@ bool wxWindowMSW::HandleDropFiles(WXWPARAM wParam)
 
         // and now get the file name
         ::DragQueryFile(hFilesInfo, wIndex,
-                        files[wIndex].GetWriteBuf(len), len);
-
-        files[wIndex].UngetWriteBuf();
+                        wxStringBuffer(files[wIndex], len), len);
     }
     DragFinish (hFilesInfo);
 
@@ -4645,7 +4718,8 @@ bool wxWindowMSW::MSWOnScroll(int orientation, WXWORD wParam,
                                                               : SB_VERT,
                                   &scrollInfo) )
             {
-                wxLogLastError(_T("GetScrollInfo"));
+                // Not neccessarily an error, if there are no scrollbars yet.
+                // wxLogLastError(_T("GetScrollInfo"));
             }
 
             event.SetPosition(scrollInfo.nTrackPos);