X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e949bf13c5a79f20b91eaed882d3246b1023718f..0e448231102ecab3ce01647e98ec156f7bf5b8bb:/src/msw/mdi.cpp diff --git a/src/msw/mdi.cpp b/src/msw/mdi.cpp index 46f92ba543..9edbdbf703 100644 --- a/src/msw/mdi.cpp +++ b/src/msw/mdi.cpp @@ -67,8 +67,6 @@ extern const wxChar *wxMDIFrameClassName; // from app.cpp extern const wxChar *wxMDIChildFrameClassName; extern const wxChar *wxMDIChildFrameClassNameNoRedraw; -extern wxWindow *wxWndHook; // from window.cpp - extern void wxAssociateWinWithHandle(HWND hWnd, wxWindow *win); extern void wxRemoveHandleAssociation(wxWindow *win); @@ -163,10 +161,6 @@ bool wxMDIParentFrame::Create(wxWindow *parent, long style, const wxString& name) { - m_defaultIcon = (WXHICON) (wxSTD_MDIPARENTFRAME_ICON - ? wxSTD_MDIPARENTFRAME_ICON - : wxDEFAULT_MDIPARENTFRAME_ICON); - m_clientWindow = NULL; m_currentChild = NULL; @@ -196,44 +190,22 @@ bool wxMDIParentFrame::Create(wxWindow *parent, SetName(name); m_windowStyle = style; - if (parent) parent->AddChild(this); + if ( parent ) + parent->AddChild(this); if ( id > -1 ) m_windowId = id; else - m_windowId = (int)NewControlId(); + m_windowId = NewControlId(); - int x = pos.x; - int y = pos.y; - int width = size.x; - int height = size.y; + long exflags; + long msflags = MSWGetCreateWindowFlags(&exflags); - DWORD msflags = WS_OVERLAPPED; - if (style & wxMINIMIZE_BOX) - msflags |= WS_MINIMIZEBOX; - if (style & wxMAXIMIZE_BOX) - msflags |= WS_MAXIMIZEBOX; - if (style & wxTHICK_FRAME) - msflags |= WS_THICKFRAME; - if (style & wxSYSTEM_MENU) - msflags |= WS_SYSMENU; - if ((style & wxMINIMIZE) || (style & wxICONIZE)) - msflags |= WS_MINIMIZE; - if (style & wxMAXIMIZE) - msflags |= WS_MAXIMIZE; - if (style & wxCAPTION) - msflags |= WS_CAPTION; - - if (style & wxCLIP_CHILDREN) - msflags |= WS_CLIPCHILDREN; - - if ( !wxWindow::MSWCreate(m_windowId, - parent, - wxMDIFrameClassName, - this, + if ( !wxWindow::MSWCreate(wxMDIFrameClassName, title, - x, y, width, height, - msflags) ) + pos, size, + msflags, + exflags) ) { return FALSE; } @@ -270,19 +242,20 @@ wxMDIParentFrame::~wxMDIParentFrame() } } +#if wxUSE_MENUS_NATIVE + void wxMDIParentFrame::InternalSetMenuBar() { -// HMENU subMenu = GetSubMenu((HMENU) m_windowMenu, 0); - m_parentFrameActive = TRUE; - HMENU subMenu = (HMENU) 0; - if (GetWindowMenu()) - subMenu = (HMENU) GetWindowMenu()->GetHMenu(); + wxMenu *menu = GetWindowMenu(); + HMENU subMenu = menu ? GetHmenuOf(menu) : 0; InsertWindowMenu(GetClientWindow(), m_hMenu, subMenu); } +#endif // wxUSE_MENUS_NATIVE + void wxMDIParentFrame::SetWindowMenu(wxMenu* menu) { if (m_windowMenu) @@ -348,6 +321,12 @@ void wxMDIParentFrame::OnSysColourChanged(wxSysColourChangedEvent& event) event.Skip(); } +WXHICON wxMDIParentFrame::GetDefaultIcon() const +{ + return (WXHICON)(wxSTD_MDIPARENTFRAME_ICON ? wxSTD_MDIPARENTFRAME_ICON + : wxDEFAULT_MDIPARENTFRAME_ICON); +} + // --------------------------------------------------------------------------- // MDI operations // --------------------------------------------------------------------------- @@ -646,9 +625,6 @@ bool wxMDIChildFrame::Create(wxMDIParentFrame *parent, long style, const wxString& name) { - m_defaultIcon = (WXHICON)(wxSTD_MDICHILDFRAME_ICON ? wxSTD_MDICHILDFRAME_ICON - : wxDEFAULT_MDICHILDFRAME_ICON); - SetName(name); wxWindowBase::Show(TRUE); // MDI child frame starts off shown @@ -662,8 +638,6 @@ bool wxMDIChildFrame::Create(wxMDIParentFrame *parent, parent->AddChild(this); } - wxWndHook = this; - int x = pos.x; int y = pos.y; int width = size.x; @@ -716,15 +690,13 @@ bool wxMDIChildFrame::Create(wxMDIParentFrame *parent, mcs.lParam = 0; + wxWindowCreationHook hook(this); + m_hWnd = (WXHWND)::SendMessage(GetWinHwnd(parent->GetClientWindow()), WM_MDICREATE, 0, (LONG)(LPSTR)&mcs); - wxWndHook = NULL; wxAssociateWinWithHandle((HWND) GetHWND(), this); - // VZ: what's this? an act of piracy? - //SetWindowLong(GetHwnd(), 0, (long)this); - wxModelessWindows.Append(this); return TRUE; @@ -813,6 +785,12 @@ void wxMDIChildFrame::InternalSetMenuBar() parent->m_parentFrameActive = FALSE; } +WXHICON wxMDIChildFrame::GetDefaultIcon() const +{ + return (WXHICON)(wxSTD_MDICHILDFRAME_ICON ? wxSTD_MDICHILDFRAME_ICON + : wxDEFAULT_MDICHILDFRAME_ICON); +} + // --------------------------------------------------------------------------- // MDI operations // --------------------------------------------------------------------------- @@ -873,10 +851,8 @@ long wxMDIChildFrame::MSWWindowProc(WXUINT message, break; case WM_GETMINMAXINFO: - // let the default window proc calculate the size of MDI children - // frames because it is based on the size of the MDI client window, - // not on the values specified in wxWindow m_min/max variables - return MSWDefWindowProc(message, wParam, lParam); + processed = HandleGetMinMaxInfo((MINMAXINFO *)lParam); + break; case WM_MDIACTIVATE: { @@ -979,7 +955,10 @@ bool wxMDIChildFrame::HandleMDIActivate(long WXUNUSED(activate), parent->m_currentChild = NULL; HMENU parent_menu = (HMENU)parent->GetWinMenu(); - if ( parent_menu ) + + // activate the the parent menu only when there is no other child + // that has been activated + if ( parent_menu && !hwndAct ) { parent->m_parentFrameActive = TRUE; @@ -1037,6 +1016,33 @@ bool wxMDIChildFrame::HandleWindowPosChanging(void *pos) return FALSE; } +bool wxMDIChildFrame::HandleGetMinMaxInfo(void *mmInfo) +{ + MINMAXINFO *info = (MINMAXINFO *)mmInfo; + + // let the default window proc calculate the size of MDI children + // frames because it is based on the size of the MDI client window, + // not on the values specified in wxWindow m_max variables + bool processed = MSWDefWindowProc(WM_GETMINMAXINFO, 0, (LPARAM)mmInfo) != 0; + + // but allow GetSizeHints() to set the min size + if ( m_minWidth != -1 ) + { + info->ptMinTrackSize.x = m_minWidth; + + processed = TRUE; + } + + if ( m_minHeight != -1 ) + { + info->ptMinTrackSize.y = m_minHeight; + + processed = TRUE; + } + + return TRUE; +} + // --------------------------------------------------------------------------- // MDI specific message translation/preprocessing // --------------------------------------------------------------------------- @@ -1161,7 +1167,7 @@ bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long style) DWORD exStyle = 0; #endif - wxWndHook = this; + wxWindowCreationHook hook(this); m_hWnd = (WXHWND)::CreateWindowEx ( exStyle, @@ -1181,7 +1187,6 @@ bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long style) } SubclassWin(m_hWnd); - wxWndHook = NULL; return TRUE; }