X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ffcb4ee424061633cedc1c0ba6c04180d5048da9..c5fc899bf29ca7d9c4e2a070e28228b430a68dd3:/src/msw/toplevel.cpp diff --git a/src/msw/toplevel.cpp b/src/msw/toplevel.cpp index 76363e5dc7..0296aac6ce 100644 --- a/src/msw/toplevel.cpp +++ b/src/msw/toplevel.cpp @@ -41,6 +41,16 @@ #include "wx/module.h" #include "wx/msw/private.h" +#if defined(__WXWINCE__) + #include + #include + #if _WIN32_WCE < 400 + #include + #endif +#include "wx/msw/wince/missing.h" +#endif + +#include "wx/msw/missing.h" #include "wx/msw/winundef.h" // This can't be undefed in winundef.h or @@ -129,9 +139,6 @@ void wxTopLevelWindowMSW::Init() m_iconized = m_maximizeOnShow = FALSE; - // unlike (almost?) all other windows, frames are created hidden - m_isShown = FALSE; - // Data to save/restore when calling ShowFullScreen m_fsStyle = 0; m_fsOldWindowStyle = 0; @@ -172,6 +179,8 @@ WXDWORD wxTopLevelWindowMSW::MSWGetStyle(long style, WXDWORD *exflags) const msflags |= WS_THICKFRAME; #endif } + else if ( exflags && ((style & wxBORDER_DOUBLE) || (style & wxBORDER_RAISED)) ) + *exflags |= WS_EX_DLGMODALFRAME; else if ( !(style & wxBORDER_NONE) ) msflags |= WS_BORDER; #ifndef __WXWINCE__ @@ -213,13 +222,15 @@ WXDWORD wxTopLevelWindowMSW::MSWGetStyle(long style, WXDWORD *exflags) const if ( exflags ) { -#if !defined(__WIN16__) if ( !(GetExtraStyle() & wxTOPLEVEL_EX_DIALOG) ) { if ( style & wxFRAME_TOOL_WINDOW ) { // create the palette-like window *exflags |= WS_EX_TOOLWINDOW; + + // tool windows shouldn't appear on the taskbar (as documented) + style |= wxFRAME_NO_TASKBAR; } // We have to solve 2 different problems here: @@ -243,7 +254,6 @@ WXDWORD wxTopLevelWindowMSW::MSWGetStyle(long style, WXDWORD *exflags) const #endif //else: nothing to do [here] } -#endif // !Win16 if ( style & wxSTAY_ON_TOP ) *exflags |= WS_EX_TOPMOST; @@ -377,25 +387,7 @@ bool wxTopLevelWindowMSW::CreateDialog(const void *dlgTemplate, // move the dialog to its initial position without forcing repainting int x, y, w, h; - if ( !MSWGetCreateWindowCoords(pos, size, x, y, w, h) ) - { - x = - w = (int)CW_USEDEFAULT; - } - - // we can't use CW_USEDEFAULT here as we're not calling CreateWindow() - // and passing CW_USEDEFAULT to MoveWindow() results in resizing the - // window to (0, 0) size which breaks quite a lot of things, e.g. the - // sizer calculation in wxSizer::Fit() - if ( w == (int)CW_USEDEFAULT ) - { - // the exact number doesn't matter, the dialog will be resized - // again soon anyhow but it should be big enough to allow - // calculation relying on "totalSize - clientSize > 0" work, i.e. - // at least greater than the title bar height - w = - h = 100; - } + (void)MSWGetCreateWindowCoords(pos, size, x, y, w, h); if ( x == (int)CW_USEDEFAULT ) { @@ -440,10 +432,13 @@ bool wxTopLevelWindowMSW::Create(wxWindow *parent, long style, const wxString& name) { - bool ret = false; - + bool ret wxDUMMY_INITIALIZE(false); + int w, h; + // init our fields Init(); + w = WidthDefault(size.x); + h = HeightDefault(size.y); m_windowStyle = style; @@ -486,12 +481,12 @@ bool wxTopLevelWindowMSW::Create(wxWindow *parent, if ( style & (wxRESIZE_BORDER | wxCAPTION) ) dlgTemplate->style |= DS_MODALFRAME; - ret = CreateDialog(dlgTemplate, title, pos, size); + ret = CreateDialog(dlgTemplate, title, pos, wxSize(w,h)); free(dlgTemplate); } else // !dialog { - ret = CreateFrame(title, pos, size); + ret = CreateFrame(title, pos, wxSize(w,h)); } if ( ret && !(GetWindowStyleFlag() & wxCLOSE_BOX) ) @@ -499,6 +494,23 @@ bool wxTopLevelWindowMSW::Create(wxWindow *parent, EnableCloseButton(false); } + // for some reason we need to manually send ourselves this message as + // otherwise the mnemonics are always shown -- even if they're configured + // to be hidden until "Alt" is pressed in the control panel + // + // this could indicate a bug somewhere else but for now this is the only + // fix we have + if ( ret ) + { + SendMessage + ( + GetHwnd(), + WM_UPDATEUISTATE, + MAKEWPARAM(UIS_INITIALIZE, UISF_HIDEFOCUS | UISF_HIDEACCEL), + 0 + ); + } + return ret; } @@ -692,10 +704,13 @@ bool wxTopLevelWindowMSW::ShowFullScreen(bool show, long style) else // fall back to the main desktop #else // wxUSE_DISPLAY { - // FIXME: implement for WinCE -#ifndef __WXWINCE__ // resize to the size of the desktop wxCopyRECTToRect(wxGetWindowRect(::GetDesktopWindow()), rect); +#ifdef __WXWINCE__ + // FIXME: size of the bottom menu (toolbar) + // should be taken in account + rect.height += rect.y; + rect.y = 0; #endif } #endif // wxUSE_DISPLAY @@ -722,12 +737,19 @@ bool wxTopLevelWindowMSW::ShowFullScreen(bool show, long style) rect.x, rect.y, rect.width, rect.height, flags); +#if defined(__WXWINCE__) && _WIN32_WCE < 400 + ::SHFullScreen(GetHwnd(), SHFS_HIDETASKBAR | SHFS_HIDESIPBUTTON); +#endif + // finally send an event allowing the window to relayout itself &c wxSizeEvent event(rect.GetSize(), GetId()); GetEventHandler()->ProcessEvent(event); } else // stop showing full screen { +#if defined(__WXWINCE__) && _WIN32_WCE < 400 + ::SHFullScreen(GetHwnd(), SHFS_SHOWTASKBAR | SHFS_SHOWSIPBUTTON); +#endif Maximize(m_fsIsMaximized); SetWindowLong(GetHwnd(),GWL_STYLE, m_fsOldWindowStyle); SetWindowPos(GetHwnd(),HWND_TOP,m_fsOldSize.x, m_fsOldSize.y, @@ -858,17 +880,22 @@ void wxTopLevelWindowMSW::OnActivate(wxActivateEvent& event) { if ( event.GetActive() ) { - // restore focus to the child which was last focused + // restore focus to the child which was last focused unless we already + // have it wxLogTrace(_T("focus"), _T("wxTLW %08x activated."), (int) m_hWnd); - wxWindow *parent = m_winLastFocused ? m_winLastFocused->GetParent() - : NULL; - if ( !parent ) + wxWindow *winFocus = FindFocus(); + if ( !winFocus || wxGetTopLevelParent(winFocus) != this ) { - parent = this; - } + wxWindow *parent = m_winLastFocused ? m_winLastFocused->GetParent() + : NULL; + if ( !parent ) + { + parent = this; + } - wxSetFocusToChild(parent, &m_winLastFocused); + wxSetFocusToChild(parent, &m_winLastFocused); + } } else // deactivating { @@ -879,23 +906,12 @@ void wxTopLevelWindowMSW::OnActivate(wxActivateEvent& event) { // let it know that it doesn't have focus any more m_winLastFocused->HandleKillFocus((WXHWND)NULL); - } - // so we NULL it out if it's a child from some other frame - wxWindow *win = m_winLastFocused; - while ( win ) - { - if ( win->IsTopLevel() ) + // and don't remember it if it's a child from some other frame + if ( wxGetTopLevelParent(m_winLastFocused) != this ) { - if ( win != this ) - { - m_winLastFocused = NULL; - } - - break; + m_winLastFocused = NULL; } - - win = win->GetParent(); } wxLogTrace(_T("focus"),