From 46fa338b6f7462b684b2d6c694849769f75a2cf9 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Mon, 19 Apr 2004 21:47:12 +0000 Subject: [PATCH] Code for single instance and bring-to-top under CE. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26869 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/app.cpp | 24 ++++++++++++++++++++++++ src/msw/toplevel.cpp | 4 ++++ src/msw/window.cpp | 8 ++++++-- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/msw/app.cpp b/src/msw/app.cpp index 7d430057a9..6c4e94bacd 100644 --- a/src/msw/app.cpp +++ b/src/msw/app.cpp @@ -99,8 +99,13 @@ extern void wxSetKeyboardHook(bool doIt); // NB: all "NoRedraw" classes must have the same names as the "normal" classes // with NR suffix - wxWindow::MSWCreate() supposes this +#ifdef __WXWINCE__ + wxChar *wxCanvasClassName; + wxChar *wxCanvasClassNameNR; +#else const wxChar *wxCanvasClassName = wxT("wxWindowClass"); const wxChar *wxCanvasClassNameNR = wxT("wxWindowClassNR"); +#endif const wxChar *wxMDIFrameClassName = wxT("wxMDIFrameClass"); const wxChar *wxMDIFrameClassNameNoRedraw = wxT("wxMDIFrameClassNR"); const wxChar *wxMDIChildFrameClassName = wxT("wxMDIChildFrameClass"); @@ -254,6 +259,20 @@ bool wxApp::Initialize(int& argc, wxChar **argv) // ensure that base cleanup is done if we return too early wxCallBaseCleanup callBaseCleanup(this); +#ifdef __WXWINCE__ + wxString tmp = GetAppName(); + tmp += wxT("ClassName"); + wxCanvasClassName = wxStrdup( tmp.c_str() ); + tmp += wxT("NR"); + wxCanvasClassNameNR = wxStrdup( tmp.c_str() ); + HWND hWnd = FindWindow( wxCanvasClassNameNR, NULL ); + if (hWnd) + { + SetForegroundWindow( (HWND)(((DWORD)hWnd)|0x01) ); + return false; + } +#endif + // the first thing to do is to check if we're trying to run an Unicode // program under Win9x w/o MSLU emulation layer - if so, abort right now // as it has no chance to work @@ -514,6 +533,11 @@ void wxApp::CleanUp() delete wxWinHandleHash; wxWinHandleHash = NULL; + +#ifdef __WXWINCE__ + free( wxCanvasClassName ); + free( wxCanvasClassNameNR ); +#endif } // ---------------------------------------------------------------------------- diff --git a/src/msw/toplevel.cpp b/src/msw/toplevel.cpp index eccae97c29..2477c11582 100644 --- a/src/msw/toplevel.cpp +++ b/src/msw/toplevel.cpp @@ -88,7 +88,11 @@ wxDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); wxWindowList wxModelessWindows; // the name of the default wxWindows class +#ifdef __WXWINCE__ +extern wxChar *wxCanvasClassName; +#else extern const wxChar *wxCanvasClassName; +#endif // ---------------------------------------------------------------------------- // wxTLWHiddenParentModule: used to manage the hidden parent window (we need a diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 3c76c6b551..b7c5b66709 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -128,7 +128,11 @@ wxMenu *wxCurrentPopupMenu = NULL; #endif // wxUSE_MENUS_NATIVE +#ifdef __WXWINCE__ +extern wxChar *wxCanvasClassName; +#else extern const wxChar *wxCanvasClassName; +#endif // true if we had already created the std colour map, used by // wxGetStdColourMap() and wxWindow::OnSysColourChanged() (FIXME-MT) @@ -1022,8 +1026,8 @@ bool wxCheckWindowWndProc(WXHWND hWnd, WXFARPROC wndProc) // 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 wxChar *wxCanvasClassName; + extern wxChar *wxCanvasClassNameNR; extern const wxChar *wxMDIFrameClassName; extern const wxChar *wxMDIFrameClassNameNoRedraw; extern const wxChar *wxMDIChildFrameClassName; -- 2.45.2