1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: MDI classes
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
21 #include "wx/dialog.h"
22 #include "wx/statusbr.h"
23 #include "wx/settings.h"
29 #include "wx/os2/private.h"
33 // ---------------------------------------------------------------------------
35 // ---------------------------------------------------------------------------
37 extern wxWindowList wxModelessWindows
; // from dialog.cpp
38 extern wxMenu
*wxCurrentPopupMenu
;
40 extern wxWindow
*wxWndHook
; // from window.cpp
42 extern void wxAssociateWinWithHandle(HWND hWnd
, wxWindow
*win
);
44 static HWND invalidHandle
= 0;
46 // ---------------------------------------------------------------------------
48 // ---------------------------------------------------------------------------
50 static const int IDM_WINDOWTILE
= 4001;
51 static const int IDM_WINDOWTILEHOR
= 4001;
52 static const int IDM_WINDOWCASCADE
= 4002;
53 static const int IDM_WINDOWICONS
= 4003;
54 static const int IDM_WINDOWNEXT
= 4004;
55 static const int IDM_WINDOWTILEVERT
= 4005;
57 // This range gives a maximum of 500 MDI children. Should be enough :-)
58 static const int wxFIRST_MDI_CHILD
= 4100;
59 static const int wxLAST_MDI_CHILD
= 4600;
61 // Status border dimensions
62 static const int wxTHICK_LINE_BORDER
= 3;
63 static const int wxTHICK_LINE_WIDTH
= 1;
65 // ---------------------------------------------------------------------------
67 // ---------------------------------------------------------------------------
69 // set the MDI menus (by sending the WM_MDISETMENU message) and update the menu
70 // of the parent of win (which is supposed to be the MDI client window)
71 static void MDISetMenu(wxWindow
*win
, HMENU hmenuFrame
, HMENU hmenuWindow
);
73 // insert the window menu (subMenu) into menu just before "Help" submenu or at
74 // the very end if not found
75 static void InsertWindowMenu(wxWindow
*win
, WXHMENU menu
, HMENU subMenu
);
77 // is this an id of an MDI child?
78 inline bool IsMdiCommandId(int id
)
80 return (id
>= wxFIRST_MDI_CHILD
) && (id
<= wxLAST_MDI_CHILD
);
83 static void UnpackMDIActivate(WXWPARAM wParam
, WXLPARAM lParam
,
84 WXWORD
*activate
, WXHWND
*hwndAct
, WXHWND
*hwndDeact
);
86 // ===========================================================================
88 // ===========================================================================
90 // ---------------------------------------------------------------------------
92 // ---------------------------------------------------------------------------
94 IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame
, wxFrame
)
95 IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame
, wxFrame
)
96 IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow
, wxWindow
)
98 BEGIN_EVENT_TABLE(wxMDIParentFrame
, wxFrame
)
99 EVT_SIZE(wxMDIParentFrame::OnSize
)
100 EVT_SYS_COLOUR_CHANGED(wxMDIParentFrame::OnSysColourChanged
)
103 BEGIN_EVENT_TABLE(wxMDIClientWindow
, wxWindow
)
104 EVT_SCROLL(wxMDIClientWindow::OnScroll
)
107 // ===========================================================================
108 // wxMDIParentFrame: the frame which contains the client window which manages
110 // ===========================================================================
112 wxMDIParentFrame::wxMDIParentFrame()
114 m_clientWindow
= NULL
;
115 m_currentChild
= NULL
;
117 m_parentFrameActive
= TRUE
;
120 bool wxMDIParentFrame::Create(wxWindow
*parent
,
122 const wxString
& title
,
126 const wxString
& name
)
128 m_hDefaultIcon
= (WXHICON
) (wxSTD_MDIPARENTFRAME_ICON
? wxSTD_MDIPARENTFRAME_ICON
: wxDEFAULT_MDIPARENTFRAME_ICON
);
130 m_clientWindow
= NULL
;
131 m_currentChild
= NULL
;
133 m_parentFrameActive
= TRUE
;
136 wxTopLevelWindows
.Append(this);
139 wxWindowBase::Show(TRUE
); // MDI child frame starts off shown
140 m_windowStyle
= style
;
142 if (parent
) parent
->AddChild(this);
147 m_windowId
= (int)NewControlId();
154 // TODO: m_windowMenu = (WXHMENU) ::LoadMenu(wxGetInstance(), wxT("wxWindowMenu"));
156 DWORD msflags = WS_OVERLAPPED;
157 if (style & wxMINIMIZE_BOX)
158 msflags |= WS_MINIMIZEBOX;
159 if (style & wxMAXIMIZE_BOX)
160 msflags |= WS_MAXIMIZEBOX;
161 if (style & wxTHICK_FRAME)
162 msflags |= WS_THICKFRAME;
163 if (style & wxSYSTEM_MENU)
164 msflags |= WS_SYSMENU;
165 if ((style & wxMINIMIZE) || (style & wxICONIZE))
166 msflags |= WS_MINIMIZE;
167 if (style & wxMAXIMIZE)
168 msflags |= WS_MAXIMIZE;
169 if (style & wxCAPTION)
170 msflags |= WS_CAPTION;
172 if (style & wxCLIP_CHILDREN)
173 msflags |= WS_CLIPCHILDREN;
175 wxWindow::MSWCreate(m_windowId, parent, wxMDIFrameClassName, this, title, x, y, width, height,
178 wxModelessWindows
.Append(this);
183 wxMDIParentFrame::~wxMDIParentFrame()
187 // TODO: ::DestroyMenu((HMENU)m_windowMenu);
190 if ( m_clientWindow
)
192 if ( m_clientWindow
->OS2GetOldWndProc() )
193 m_clientWindow
->UnsubclassWin();
195 m_clientWindow
->SetHWND(0);
196 delete m_clientWindow
;
200 void wxMDIParentFrame::InternalSetMenuBar()
204 HMENU subMenu = GetSubMenu((HMENU) m_windowMenu, 0);
206 m_parentFrameActive = TRUE;
208 InsertWindowMenu(GetClientWindow(), m_hMenu, subMenu);
212 void wxMDIParentFrame::OnSize(wxSizeEvent
& event
)
216 if ( GetClientWindow() )
219 GetClientSize(&width, &height);
221 GetClientWindow()->SetSize(0, 0, width, height);
226 // Returns the active MDI child window
227 wxMDIChildFrame
*wxMDIParentFrame::GetActiveChild() const
229 HWND hWnd
= 0; // TODO: (HWND)::SendMessage(GetWinHwnd(GetClientWindow()),
230 // WM_MDIGETACTIVE, 0, 0L);
234 return (wxMDIChildFrame
*)wxFindWinFromHandle((WXHWND
) hWnd
);
237 // Create the client window class (don't Create the window, just return a new
239 wxMDIClientWindow
*wxMDIParentFrame::OnCreateClient()
241 return new wxMDIClientWindow
;
244 // Responds to colour changes, and passes event on to children.
245 void wxMDIParentFrame::OnSysColourChanged(wxSysColourChangedEvent
& event
)
247 if ( m_clientWindow
)
249 m_clientWindow
->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
250 m_clientWindow
->Refresh();
256 // ---------------------------------------------------------------------------
258 // ---------------------------------------------------------------------------
260 void wxMDIParentFrame::Cascade()
262 // TODO: ::SendMessage(GetWinHwnd(GetClientWindow()), WM_MDICASCADE, 0, 0);
265 // TODO: add a direction argument (hor/vert)
266 void wxMDIParentFrame::Tile()
268 // TODO: ::SendMessage(GetWinHwnd(GetClientWindow()), WM_MDITILE, MDITILE_HORIZONTAL, 0);
271 void wxMDIParentFrame::ArrangeIcons()
273 // TODO: ::SendMessage(GetWinHwnd(GetClientWindow()), WM_MDIICONARRANGE, 0, 0);
276 void wxMDIParentFrame::ActivateNext()
278 // TODO: ::SendMessage(GetWinHwnd(GetClientWindow()), WM_MDINEXT, 0, 0);
281 void wxMDIParentFrame::ActivatePrevious()
283 // TODO: ::SendMessage(GetWinHwnd(GetClientWindow()), WM_MDINEXT, 0, 1);
286 // ---------------------------------------------------------------------------
287 // the MDI parent frame window proc
288 // ---------------------------------------------------------------------------
290 MRESULT
wxMDIParentFrame::OS2WindowProc(WXUINT message
,
295 bool processed
= FALSE
;
303 WXWORD state, minimized;
305 UnpackActivate(wParam, lParam, &state, &minimized, &hwnd);
307 processed = HandleActivate(state, minimized != 0, hwnd);
315 UnpackCommand(wParam, lParam, &id, &hwnd, &cmd);
317 (void)HandleCommand(id, cmd, hwnd);
319 // even if the frame didn't process it, there is no need to try it
320 // once again (i.e. call wxFrame::HandleCommand()) - we just dud it,
321 // so pretend we processed the message anyhow
325 // always pass this message DefFrameProc(), otherwise MDI menu
326 // commands (and sys commands - more surprizingly!) won't work
327 MSWDefWindowProc(message, wParam, lParam);
331 m_clientWindow = OnCreateClient();
332 // Uses own style for client style
333 if ( !m_clientWindow->CreateClient(this, GetWindowStyleFlag()) )
335 wxLogMessage(_("Failed to create MDI parent frame."));
346 // we erase background ourselves
354 UnpackMenuSelect(wParam, lParam, &item, &flags, &hmenu);
356 if ( m_parentFrameActive )
358 processed = HandleMenuSelect(item, flags, hmenu);
360 else if (m_currentChild)
362 processed = m_currentChild->
363 HandleMenuSelect(item, flags, hmenu);
369 // as we don't (usually) resize the MDI client to exactly fit the
370 // client area (we put it below the toolbar, above statusbar &c),
371 // we should not pass this one to DefFrameProc
376 rc
= wxFrame::OS2WindowProc(message
, wParam
, lParam
);
381 bool wxMDIParentFrame::HandleActivate(int state
, bool minimized
, WXHWND activate
)
383 bool processed
= FALSE
;
387 if ( wxWindow::HandleActivate(state, minimized, activate) )
393 // If this window is an MDI parent, we must also send an OnActivate message
394 // to the current child.
395 if ( (m_currentChild != NULL) &&
396 ((state == WA_ACTIVE) || (state == WA_CLICKACTIVE)) )
398 wxActivateEvent event(wxEVT_ACTIVATE, TRUE, m_currentChild->GetId());
399 event.SetEventObject( m_currentChild );
400 if ( m_currentChild->GetEventHandler()->ProcessEvent(event) )
407 bool wxMDIParentFrame::HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND hwnd
)
409 // In case it's e.g. a toolbar.
412 wxWindow
*win
= wxFindWinFromHandle(hwnd
);
414 return FALSE
; // Need to get wxWindow for OS/2 up to date: win->OS2Command(cmd, id);
417 // is it one of standard MDI commands?
425 case IDM_WINDOWCASCADE:
427 wParam = MDITILE_SKIPDISABLED;
430 case IDM_WINDOWTILEHOR:
431 wParam |= MDITILE_HORIZONTAL;
434 case IDM_WINDOWTILEVERT:
436 wParam = MDITILE_VERTICAL;
438 wParam |= MDITILE_SKIPDISABLED;
441 case IDM_WINDOWICONS:
442 msg = WM_MDIICONARRANGE;
455 // TODO: ::SendMessage(GetWinHwnd(GetClientWindow()), msg, wParam, 0);
460 // FIXME VZ: what does this test do??
463 return FALSE
; // Get WndProc to call default proc
466 if ( IsMdiCommandId(id
) )
468 wxWindowList::Node
* node
= GetChildren().GetFirst();
471 wxWindow
* child
= node
->GetData();
472 if ( child
->GetHWND() )
474 long childId
= wxGetWindowId(child
->GetHWND());
475 if (childId
== (long)id
)
477 // TODO: ::SendMessage( GetWinHwnd(GetClientWindow()),
479 // (WPARAM)child->GetHWND(), 0);
483 node
= node
->GetNext();
486 else if ( m_parentFrameActive
)
488 return ProcessCommand(id
);
490 else if ( m_currentChild
)
492 return m_currentChild
->HandleCommand(id
, cmd
, hwnd
);
496 // this shouldn't happen because it means that our messages are being
497 // lost (they're not sent to the parent frame nor to the children)
498 wxFAIL_MSG(wxT("MDI parent frame is not active, "
499 "yet there is no active MDI child?"));
505 MRESULT
wxMDIParentFrame::OS2DefWindowProc(WXUINT message
,
510 if ( GetClientWindow() )
511 clientWnd
= GetClientWindow()->GetHWND();
515 // TODO: return DefFrameProc(GetHwnd(), (HWND)clientWnd, message, wParam, lParam);
519 bool wxMDIParentFrame::OS2TranslateMessage(WXMSG
* msg
)
523 if ( m_currentChild && m_currentChild->GetHWND() &&
524 m_currentChild->OS2TranslateMessage(msg) )
529 if ( m_acceleratorTable.Translate(this, msg) )
534 if ( pMsg->message == WM_KEYDOWN || pMsg->message == WM_SYSKEYDOWN )
536 if ( ::TranslateMDISysAccel(GetWinHwnd(GetClientWindow()), pMsg))
543 // ===========================================================================
545 // ===========================================================================
547 wxMDIChildFrame::wxMDIChildFrame()
551 bool wxMDIChildFrame::Create(wxMDIParentFrame
*parent
,
553 const wxString
& title
,
557 const wxString
& name
)
559 m_hDefaultIcon
= (WXHICON
)(wxSTD_MDICHILDFRAME_ICON
? wxSTD_MDICHILDFRAME_ICON
560 : wxDEFAULT_MDICHILDFRAME_ICON
);
567 m_windowId
= (int)NewControlId();
571 parent
->AddChild(this);
585 mcs.szClass = wxMDIChildFrameClassName;
587 mcs.hOwner = wxGetInstance();
591 mcs.x = CW_USEDEFAULT;
596 mcs.y = CW_USEDEFAULT;
601 mcs.cx = CW_USEDEFAULT;
606 mcs.cy = CW_USEDEFAULT;
608 DWORD msflags = WS_OVERLAPPED | WS_CLIPCHILDREN;
609 if (style & wxMINIMIZE_BOX)
610 msflags |= WS_MINIMIZEBOX;
611 if (style & wxMAXIMIZE_BOX)
612 msflags |= WS_MAXIMIZEBOX;
613 if (style & wxTHICK_FRAME)
614 msflags |= WS_THICKFRAME;
615 if (style & wxSYSTEM_MENU)
616 msflags |= WS_SYSMENU;
617 if ((style & wxMINIMIZE) || (style & wxICONIZE))
618 msflags |= WS_MINIMIZE;
619 if (style & wxMAXIMIZE)
620 msflags |= WS_MAXIMIZE;
621 if (style & wxCAPTION)
622 msflags |= WS_CAPTION;
628 DWORD Return
= 0; // SendMessage(GetWinHwnd(parent->GetClientWindow()),
629 // WM_MDICREATE, 0, (LONG)(LPSTR)&mcs);
630 m_hWnd
= (WXHWND
)Return
;
633 wxAssociateWinWithHandle((HWND
) GetHWND(), this);
635 // VZ: what's this? an act of piracy?
636 //SetWindowLong(GetHwnd(), 0, (long)this);
638 wxModelessWindows
.Append(this);
642 wxMDIChildFrame::~wxMDIChildFrame()
647 // Set the client size (i.e. leave the calculation of borders etc.
649 void wxMDIChildFrame::DoSetClientSize(int width
, int height
)
651 HWND hWnd
= GetHwnd();
656 ::GetClientRect(hWnd, &rect);
659 GetWindowRect(hWnd, &rect2);
661 // Find the difference between the entire window (title bar and all)
662 // and the client area; add this to the new client size to move the
664 int actual_width = rect2.right - rect2.left - rect.right + width;
665 int actual_height = rect2.bottom - rect2.top - rect.bottom + height;
670 GetStatusBar()->GetSize(&sx, &sy);
675 point.x = rect2.left;
678 // If there's an MDI parent, must subtract the parent's top left corner
679 // since MoveWindow moves relative to the parent
680 wxMDIParentFrame *mdiParent = (wxMDIParentFrame *)GetParent();
681 ::ScreenToClient((HWND) mdiParent->GetClientWindow()->GetHWND(), &point);
683 MoveWindow(hWnd, point.x, point.y, actual_width, actual_height, (BOOL)TRUE);
685 wxSizeEvent event(wxSize(width, height), m_windowId);
686 event.SetEventObject( this );
687 GetEventHandler()->ProcessEvent(event);
691 void wxMDIChildFrame::DoGetPosition(int *x
, int *y
) const
696 GetWindowRect(GetHwnd(), &rect);
701 // Since we now have the absolute screen coords,
702 // if there's a parent we must subtract its top left corner
703 wxMDIParentFrame *mdiParent = (wxMDIParentFrame *)GetParent();
704 ::ScreenToClient((HWND) mdiParent->GetClientWindow()->GetHWND(), &point);
711 void wxMDIChildFrame::InternalSetMenuBar()
716 wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent();
718 HMENU subMenu = GetSubMenu((HMENU)parent->GetWindowMenu(), 0);
720 InsertWindowMenu(parent->GetClientWindow(), m_hMenu, subMenu);
722 parent->m_parentFrameActive = FALSE;
726 // ---------------------------------------------------------------------------
728 // ---------------------------------------------------------------------------
730 void wxMDIChildFrame::Maximize(bool maximize
)
732 wxMDIParentFrame
*parent
= (wxMDIParentFrame
*)GetParent();
735 if ( parent && parent->GetClientWindow() )
737 ::SendMessage(GetWinHwnd(parent->GetClientWindow()),
738 maximize ? WM_MDIMAXIMIZE : WM_MDIRESTORE,
739 (WPARAM)GetHwnd(), 0);
744 void wxMDIChildFrame::Restore()
748 wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent();
749 if ( parent && parent->GetClientWindow() )
751 ::SendMessage(GetWinHwnd(parent->GetClientWindow()), WM_MDIRESTORE,
752 (WPARAM) GetHwnd(), 0);
757 void wxMDIChildFrame::Activate()
761 wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent();
762 if ( parent && parent->GetClientWindow() )
764 ::SendMessage(GetWinHwnd(parent->GetClientWindow()), WM_MDIACTIVATE,
765 (WPARAM) GetHwnd(), 0);
770 // ---------------------------------------------------------------------------
771 // MDI window proc and message handlers
772 // ---------------------------------------------------------------------------
774 MRESULT
wxMDIChildFrame::OS2WindowProc(WXUINT message
,
779 bool processed
= FALSE
;
789 UnpackCommand((WXWPARAM)wParam, (WXLPARAM)lParam,
792 processed = HandleCommand(id, cmd, (WXHWND)hwnd);
796 case WM_GETMINMAXINFO:
797 // let the default window proc calculate the size of MDI children
798 // frames because it is based on the size of the MDI client window,
799 // not on the values specified in wxWindow m_min/max variables
800 return MSWDefWindowProc(message, wParam, lParam);
805 WXHWND hwndAct, hwndDeact;
806 UnpackMDIActivate(wParam, lParam, &act, &hwndAct, &hwndDeact);
808 processed = HandleMDIActivate(act, hwndAct, hwndDeact);
813 // must pass WM_MOVE to DefMDIChildProc() to recalculate MDI client
814 // scrollbars if necessary
819 // must pass WM_SIZE to DefMDIChildProc(), otherwise many weird
821 MSWDefWindowProc(message, wParam, lParam);
825 // DefMDIChildProc handles SC_{NEXT/PREV}WINDOW here, so pass it
826 // the message (the base class version does not)
827 return MSWDefWindowProc(message, wParam, lParam);
829 case WM_WINDOWPOSCHANGING:
830 processed = HandleWindowPosChanging((LPWINDOWPOS)lParam);
835 rc
= wxFrame::OS2WindowProc(message
, wParam
, lParam
);
840 bool wxMDIChildFrame::HandleSize(int x
, int y
, WXUINT id
)
842 HWND hwnd
= GetHwnd();
844 if ( !hwnd
|| hwnd
== invalidHandle
)
865 // forward WM_SIZE to status bar control
866 #if wxUSE_NATIVE_STATUSBAR
867 if (m_frameStatusBar && m_frameStatusBar->IsKindOf(CLASSINFO(wxStatusBar95)))
869 wxSizeEvent event(wxSize(x, y), m_frameStatusBar->GetId());
870 event.SetEventObject( m_frameStatusBar );
872 ((wxStatusBar95 *)m_frameStatusBar)->OnSize(event);
874 #endif // wxUSE_NATIVE_STATUSBAR
879 return wxWindow::HandleSize(x, y, id);
889 bool wxMDIChildFrame::HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND hwnd
)
891 // In case it's e.g. a toolbar.
894 wxWindow
*win
= wxFindWinFromHandle(hwnd
);
896 // Fix dependent stuff return win->OS2Command(cmd, id);
899 if (wxCurrentPopupMenu
)
901 wxMenu
*popupMenu
= wxCurrentPopupMenu
;
902 wxCurrentPopupMenu
= NULL
;
903 // Fix dependent stuff if (popupMenu->OS2Command(cmd, id))
907 if (GetMenuBar() && GetMenuBar()->FindItem(id
))
918 bool wxMDIChildFrame::HandleMDIActivate(long WXUNUSED(activate
),
922 wxMDIParentFrame
*parent
= (wxMDIParentFrame
*)GetParent();
928 if ( m_hWnd
== hwndAct
)
931 parent
->m_currentChild
= this;
933 HMENU child_menu
= (HMENU
)GetWinMenu();
936 parent
->m_parentFrameActive
= FALSE
;
938 menuToSet
= child_menu
;
941 else if ( m_hWnd
== hwndDeact
)
943 wxASSERT_MSG( parent
->m_currentChild
== this,
944 wxT("can't deactivate MDI child which wasn't active!") );
947 parent
->m_currentChild
= NULL
;
949 HMENU parent_menu
= (HMENU
)parent
->GetWinMenu();
952 parent
->m_parentFrameActive
= TRUE
;
954 menuToSet
= parent_menu
;
959 // we have nothing to with it
965 HMENU subMenu
= 0; // TODO: GetSubMenu((HMENU) parent->GetWindowMenu(), 0);
967 MDISetMenu(parent
->GetClientWindow(), menuToSet
, subMenu
);
970 wxActivateEvent
event(wxEVT_ACTIVATE
, activated
, m_windowId
);
971 event
.SetEventObject( this );
973 return GetEventHandler()->ProcessEvent(event
);
976 bool wxMDIChildFrame::HandleWindowPosChanging(void *pos
)
978 // WINDOWPOS *lpPos = (WINDOWPOS *)pos;
982 // ---------------------------------------------------------------------------
983 // MDI specific message translation/preprocessing
984 // ---------------------------------------------------------------------------
986 MRESULT
wxMDIChildFrame::OS2DefWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
990 return DefMDIChildProc(GetHwnd(),
991 (UINT)message, (WPARAM)wParam, (LPARAM)lParam);
996 bool wxMDIChildFrame::OS2TranslateMessage(WXMSG
* msg
)
999 return m_acceleratorTable
.Translate(GetParent()->GetHWND(), msg
);
1002 #endif //wxUSE_ACCEL
1006 // ---------------------------------------------------------------------------
1008 // ---------------------------------------------------------------------------
1010 void wxMDIChildFrame::OS2DestroyWindow()
1012 // get wxWindow up to date OS2DetachWindowMenu();
1013 invalidHandle
= GetHwnd();
1015 wxMDIParentFrame
*parent
= (wxMDIParentFrame
*)GetParent();
1017 // Must make sure this handle is invalidated (set to NULL) since all sorts
1018 // of things could happen after the child client is destroyed, but before
1019 // the wxFrame is destroyed.
1021 HWND oldHandle
= (HWND
)GetHWND();
1022 // TODO: SendMessage(GetWinHwnd(parent->GetClientWindow()), WM_MDIDESTROY,
1023 // (WPARAM)oldHandle, 0);
1028 // TODO: ::DestroyMenu((HMENU) m_hMenu);
1034 // Change the client window's extended style so we don't get a client edge
1035 // style when a child is maximised (a double border looks silly.)
1036 bool wxMDIChildFrame::ResetWindowStyle(void *vrect
)
1041 // ===========================================================================
1042 // wxMDIClientWindow: the window of predefined (by Windows) class which
1043 // contains the child frames
1044 // ===========================================================================
1046 bool wxMDIClientWindow::CreateClient(wxMDIParentFrame
*parent
, long style
)
1048 m_backgroundColour
= wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
);
1052 CLIENTCREATESTRUCT ccs;
1053 m_windowStyle = style;
1056 ccs.hWindowMenu = (HMENU)parent->GetWindowMenu();
1057 ccs.idFirstChild = wxFIRST_MDI_CHILD;
1059 DWORD msStyle = WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN;
1060 if ( style & wxHSCROLL )
1061 msStyle |= WS_HSCROLL;
1062 if ( style & wxVSCROLL )
1063 msStyle |= WS_VSCROLL;
1065 #if defined(__WIN95__)
1066 DWORD exStyle = WS_EX_CLIENTEDGE;
1072 m_hWnd = (WXHWND)::CreateWindowEx
1082 (LPSTR)(LPCLIENTCREATESTRUCT)&ccs);
1085 wxLogLastError("CreateWindowEx(MDI client)");
1090 SubclassWin(m_hWnd);
1096 // Explicitly call default scroll behaviour
1097 void wxMDIClientWindow::OnScroll(wxScrollEvent
& event
)
1099 // Note: for client windows, the scroll position is not set in
1100 // WM_HSCROLL, WM_VSCROLL, so we can't easily determine what
1101 // scroll position we're at.
1102 // This makes it hard to paint patterns or bitmaps in the background,
1103 // and have the client area scrollable as well.
1105 if ( event
.GetOrientation() == wxHORIZONTAL
)
1106 m_scrollX
= event
.GetPosition(); // Always returns zero!
1108 m_scrollY
= event
.GetPosition(); // Always returns zero!
1113 // ---------------------------------------------------------------------------
1114 // non member functions
1115 // ---------------------------------------------------------------------------
1117 static void MDISetMenu(wxWindow
*win
, HMENU hmenuFrame
, HMENU hmenuWindow
)
1121 ::SendMessage(GetWinHwnd(win), WM_MDISETMENU,
1122 (WPARAM)hmenuFrame, (LPARAM)hmenuWindow);
1123 // update menu bar of the parent window
1124 wxWindow *parent = win->GetParent();
1125 wxCHECK_RET( parent, wxT("MDI client without parent frame? weird...") );
1127 ::DrawMenuBar(GetWinHwnd(parent));
1131 static void InsertWindowMenu(wxWindow
*win
, WXHMENU menu
, HMENU subMenu
)
1134 // Try to insert Window menu in front of Help, otherwise append it.
1135 HMENU hmenu = (HMENU)menu;
1136 int N = GetMenuItemCount(hmenu);
1137 bool success = FALSE;
1138 for ( int i = 0; i < N; i++ )
1141 int chars = GetMenuString(hmenu, i, buf, WXSIZEOF(buf), MF_BYPOSITION);
1144 wxLogLastError(wxT("GetMenuString"));
1149 if ( wxStripMenuCodes(wxString(buf)).IsSameAs(wxT("Help")) )
1152 ::InsertMenu(hmenu, i, MF_BYPOSITION | MF_POPUP | MF_STRING,
1153 (UINT)subMenu, wxT("&Window"));
1160 ::AppendMenu(hmenu, MF_POPUP, (UINT)subMenu, wxT("&Window"));
1162 MDISetMenu(win, hmenu, subMenu);
1166 static void UnpackMDIActivate(WXWPARAM wParam
, WXLPARAM lParam
,
1167 WXWORD
*activate
, WXHWND
*hwndAct
, WXHWND
*hwndDeact
)
1170 *hwndAct
= (WXHWND
)lParam
;
1171 *hwndDeact
= (WXHWND
)wParam
;