]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/app.cpp
zipstrm link fix
[wxWidgets.git] / src / msw / app.cpp
index caf8b6e6967ef696b0f1c8d020c35435f4c4d978..dc4e711541d8e0e4be1bc4254f96d73e88d0f2d6 100644 (file)
@@ -19,6 +19,7 @@
 
 #ifdef __GNUG__
     #pragma implementation "app.h"
+    #pragma implementation "appbase.h"
 #endif
 
 // For compilers that support precompilation, includes "wx.h".
@@ -43,7 +44,8 @@
     #include "wx/msgdlg.h"
     #include "wx/intl.h"
     #include "wx/dynarray.h"
-    #include "wx/wxchar.h"
+#   include "wx/wxchar.h"
+#   include "wx/icon.h"
 #endif
 
 #include "wx/log.h"
@@ -80,7 +82,7 @@
 #include <string.h>
 #include <ctype.h>
 
-#if (defined(__WIN95__) && !defined(__GNUWIN32__)) || defined(__TWIN32__)
+#if (defined(__WIN95__) && !defined(__GNUWIN32__)) || defined(__TWIN32__) || defined(wxUSE_NORLANDER_HEADERS)
     #include <commctrl.h>
 #endif
 
@@ -106,9 +108,15 @@ MSG s_currentMsg;
 wxApp *wxTheApp = NULL;
 
 // FIXME why not const? and not static?
+
+// NB: all "NoRedraw" classes must have the same names as the "normal" classes
+//     with NR suffix - wxWindow::MSWCreate() supposes this
 wxChar wxFrameClassName[]         = _T("wxFrameClass");
+wxChar wxFrameClassNameNoRedraw[] = _T("wxFrameClassNR");
 wxChar wxMDIFrameClassName[]      = _T("wxMDIFrameClass");
+wxChar wxMDIFrameClassNameNoRedraw[] = _T("wxMDIFrameClassNR");
 wxChar wxMDIChildFrameClassName[] = _T("wxMDIChildFrameClass");
+wxChar wxMDIChildFrameClassNameNoRedraw[] = _T("wxMDIChildFrameClassNR");
 wxChar wxPanelClassName[]         = _T("wxPanelClass");
 wxChar wxCanvasClassName[]        = _T("wxCanvasClass");
 
@@ -202,15 +210,19 @@ bool wxApp::Initialize()
 
 #endif // __WIN95__
 
+#if wxUSE_OLE
+
+#ifdef __WIN16__
     // for OLE, enlarge message queue to be as large as possible
     int iMsg = 96;
-    while (!SetMessageQueue(iMsg) && (iMsg -= 8));
+    while (!SetMessageQueue(iMsg) && (iMsg -= 8))
+        ;
+#endif // Win16
 
-#if wxUSE_OLE
     // we need to initialize OLE library
     if ( FAILED(::OleInitialize(NULL)) )
         wxLogError(_("Cannot initialize OLE"));
-#endif
+#endif // wxUSE_OLE
 
 #if wxUSE_CTL3D
     if (!Ctl3dRegister(wxhInstance))
@@ -272,11 +284,15 @@ bool wxApp::RegisterWindowClasses()
 {
     WNDCLASS wndclass;
 
+    // for each class we register one with CS_(V|H)REDRAW style and one
+    // without for windows created with wxNO_FULL_REDRAW_ON_REPAINT flag
+    static const long styleNormal = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
+    static const long styleNoRedraw = CS_DBLCLKS;
+
     // the fields which are common to all classes
-    wndclass.style         = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
     wndclass.lpfnWndProc   = (WNDPROC)wxWndProc;
     wndclass.cbClsExtra    = 0;
-    wndclass.cbWndExtra    = sizeof( DWORD ); // what is this DWORD used for?
+    wndclass.cbWndExtra    = sizeof( DWORD ); // VZ: what is this DWORD used for?
     wndclass.hInstance     = wxhInstance;
     wndclass.hIcon         = (HICON) NULL;
     wndclass.hCursor       = ::LoadCursor((HINSTANCE)NULL, IDC_ARROW);
@@ -284,9 +300,7 @@ bool wxApp::RegisterWindowClasses()
 
     // Register the frame window class.
     wndclass.hbrBackground = (HBRUSH)(COLOR_APPWORKSPACE + 1);
-#ifdef _MULTIPLE_INSTANCES
-    sprintf( wxFrameClassName,"wxFrameClass%d", wxhInstance );
-#endif
+    wndclass.style         = styleNormal;
     wndclass.lpszClassName = wxFrameClassName;
 
     if ( !RegisterClass(&wndclass) )
@@ -296,9 +310,20 @@ bool wxApp::RegisterWindowClasses()
         return FALSE;
     }
 
+    // "no redraw" frame
+    wndclass.lpszClassName = wxFrameClassNameNoRedraw;
+    wndclass.style         = styleNoRedraw;
+
+    if ( !RegisterClass(&wndclass) )
+    {
+        wxLogLastError("RegisterClass(no redraw frame)");
+
+        return FALSE;
+    }
+
     // Register the MDI frame window class.
     wndclass.hbrBackground = (HBRUSH)NULL; // paint MDI frame ourselves
-    wndclass.lpszClassName = wxMDIFrameClassName;
+    wndclass.lpszClassName = wxMDIFrameClassNameNoRedraw;
 
     if ( !RegisterClass(&wndclass) )
     {
@@ -307,6 +332,17 @@ bool wxApp::RegisterWindowClasses()
         return FALSE;
     }
 
+    // "no redraw" MDI frame
+    wndclass.lpszClassName = wxMDIFrameClassName;
+    wndclass.style         = styleNoRedraw;
+
+    if ( !RegisterClass(&wndclass) )
+    {
+        wxLogLastError("RegisterClass(no redraw MDI parent frame)");
+
+        return FALSE;
+    }
+
     // Register the MDI child frame window class.
     wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
     wndclass.lpszClassName = wxMDIChildFrameClassName;
@@ -318,6 +354,17 @@ bool wxApp::RegisterWindowClasses()
         return FALSE;
     }
 
+    // "no redraw" MDI child frame
+    wndclass.lpszClassName = wxMDIChildFrameClassNameNoRedraw;
+    wndclass.style         = styleNoRedraw;
+
+    if ( !RegisterClass(&wndclass) )
+    {
+        wxLogLastError("RegisterClass(no redraw MDI child)");
+
+        return FALSE;
+    }
+
     // Register the panel window class.
     wndclass.hbrBackground = (HBRUSH) GetStockObject( LTGRAY_BRUSH );
     wndclass.lpszClassName = wxPanelClassName;
@@ -707,7 +754,7 @@ int wxEntry(WXHINSTANCE hInstance)
 
 //// Static member initialization
 
-wxAppInitializerFunction wxApp::m_appInitFn = (wxAppInitializerFunction) NULL;
+wxAppInitializerFunction wxAppBase::m_appInitFn = (wxAppInitializerFunction) NULL;
 
 wxApp::wxApp()
 {
@@ -923,6 +970,15 @@ bool wxApp::ProcessMessage(WXMSG *wxmsg)
     HWND hWnd = msg->hwnd;
     wxWindow *wndThis = wxFindWinFromHandle((WXHWND)hWnd), *wnd;
 
+    // for some composite controls (like a combobox), wndThis might be NULL
+    // because the subcontrol is not a wxWindow, but only the control itself
+    // is - try to catch this case
+    while ( hWnd && !wndThis )
+    {
+        hWnd = ::GetParent(hWnd);
+        wndThis = wxFindWinFromHandle((WXHWND)hWnd);        
+    }
+
     // Try translations first; find the youngest window with
     // a translation table.
     for ( wnd = wndThis; wnd; wnd = wnd->GetParent() )
@@ -1052,21 +1108,6 @@ void wxApp::OnQueryEndSession(wxCloseEvent& event)
     }
 }
 
-wxLog* wxApp::CreateLogTarget()
-{
-    return new wxLogGui;
-}
-
-wxWindow* wxApp::GetTopWindow() const
-{
-    if (m_topWindow)
-        return m_topWindow;
-    else if (wxTopLevelWindows.GetCount() > 0)
-        return wxTopLevelWindows.GetFirst()->GetData();
-    else
-        return NULL;
-}
-
 int wxApp::GetComCtl32Version() const
 {
     // have we loaded COMCTL32 yet?
@@ -1140,6 +1181,30 @@ bool wxYield()
     return TRUE;
 }
 
+wxIcon
+wxApp::GetStdIcon(int which) const
+{
+    switch(which)
+    {
+        case wxICON_INFORMATION:
+            return wxIcon("wxICON_INFO");
+
+        case wxICON_QUESTION:
+            return wxIcon("wxICON_QUESTION");
+
+        case wxICON_EXCLAMATION:
+            return wxIcon("wxICON_WARNING");
+
+        default:
+            wxFAIL_MSG(_T("requested non existent standard icon"));
+            // still fall through
+
+        case wxICON_HAND:
+            return wxIcon("wxICON_ERROR");
+    }
+}
+
+
 HINSTANCE wxGetInstance()
 {
     return wxhInstance;