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 wxChar wxMDIFrameClassName
[];
41 extern wxChar wxMDIChildFrameClassName
[];
42 extern wxWindow
*wxWndHook
; // from window.cpp
44 extern void wxAssociateWinWithHandle(HWND hWnd
, wxWindow
*win
);
46 static HWND invalidHandle
= 0;
48 // ---------------------------------------------------------------------------
50 // ---------------------------------------------------------------------------
52 static const int IDM_WINDOWTILE
= 4001;
53 static const int IDM_WINDOWTILEHOR
= 4001;
54 static const int IDM_WINDOWCASCADE
= 4002;
55 static const int IDM_WINDOWICONS
= 4003;
56 static const int IDM_WINDOWNEXT
= 4004;
57 static const int IDM_WINDOWTILEVERT
= 4005;
59 // This range gives a maximum of 500 MDI children. Should be enough :-)
60 static const int wxFIRST_MDI_CHILD
= 4100;
61 static const int wxLAST_MDI_CHILD
= 4600;
63 // Status border dimensions
64 static const int wxTHICK_LINE_BORDER
= 3;
65 static const int wxTHICK_LINE_WIDTH
= 1;
67 // ---------------------------------------------------------------------------
69 // ---------------------------------------------------------------------------
71 // set the MDI menus (by sending the WM_MDISETMENU message) and update the menu
72 // of the parent of win (which is supposed to be the MDI client window)
73 static void MDISetMenu(wxWindow
*win
, HMENU hmenuFrame
, HMENU hmenuWindow
);
75 // insert the window menu (subMenu) into menu just before "Help" submenu or at
76 // the very end if not found
77 static void InsertWindowMenu(wxWindow
*win
, WXHMENU menu
, HMENU subMenu
);
79 // is this an id of an MDI child?
80 inline bool IsMdiCommandId(int id
)
82 return (id
>= wxFIRST_MDI_CHILD
) && (id
<= wxLAST_MDI_CHILD
);
85 static void UnpackMDIActivate(WXWPARAM wParam
, WXLPARAM lParam
,
86 WXWORD
*activate
, WXHWND
*hwndAct
, WXHWND
*hwndDeact
);
88 // ===========================================================================
90 // ===========================================================================
92 // ---------------------------------------------------------------------------
94 // ---------------------------------------------------------------------------
96 IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame
, wxFrame
)
97 IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame
, wxFrame
)
98 IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow
, wxWindow
)
100 BEGIN_EVENT_TABLE(wxMDIParentFrame
, wxFrame
)
101 EVT_SIZE(wxMDIParentFrame::OnSize
)
102 EVT_SYS_COLOUR_CHANGED(wxMDIParentFrame::OnSysColourChanged
)
105 BEGIN_EVENT_TABLE(wxMDIClientWindow
, wxWindow
)
106 EVT_SCROLL(wxMDIClientWindow::OnScroll
)
109 // ===========================================================================
110 // wxMDIParentFrame: the frame which contains the client window which manages
112 // ===========================================================================
114 wxMDIParentFrame::wxMDIParentFrame()
116 m_clientWindow
= NULL
;
117 m_currentChild
= NULL
;
119 m_parentFrameActive
= TRUE
;
122 bool wxMDIParentFrame::Create(wxWindow
*parent
,
124 const wxString
& title
,
128 const wxString
& name
)
130 m_hDefaultIcon
= (WXHICON
) (wxSTD_MDIPARENTFRAME_ICON
? wxSTD_MDIPARENTFRAME_ICON
: wxDEFAULT_MDIPARENTFRAME_ICON
);
132 m_clientWindow
= NULL
;
133 m_currentChild
= NULL
;
135 m_parentFrameActive
= TRUE
;
138 wxTopLevelWindows
.Append(this);
141 m_windowStyle
= style
;
143 if (parent
) parent
->AddChild(this);
148 m_windowId
= (int)NewControlId();
155 // TODO: m_windowMenu = (WXHMENU) ::LoadMenu(wxGetInstance(), wxT("wxWindowMenu"));
157 DWORD msflags = WS_OVERLAPPED;
158 if (style & wxMINIMIZE_BOX)
159 msflags |= WS_MINIMIZEBOX;
160 if (style & wxMAXIMIZE_BOX)
161 msflags |= WS_MAXIMIZEBOX;
162 if (style & wxTHICK_FRAME)
163 msflags |= WS_THICKFRAME;
164 if (style & wxSYSTEM_MENU)
165 msflags |= WS_SYSMENU;
166 if ((style & wxMINIMIZE) || (style & wxICONIZE))
167 msflags |= WS_MINIMIZE;
168 if (style & wxMAXIMIZE)
169 msflags |= WS_MAXIMIZE;
170 if (style & wxCAPTION)
171 msflags |= WS_CAPTION;
173 if (style & wxCLIP_CHILDREN)
174 msflags |= WS_CLIPCHILDREN;
176 wxWindow::MSWCreate(m_windowId, parent, wxMDIFrameClassName, this, title, x, y, width, height,
179 wxModelessWindows
.Append(this);
184 wxMDIParentFrame::~wxMDIParentFrame()
188 // TODO: ::DestroyMenu((HMENU)m_windowMenu);
191 if ( m_clientWindow
)
193 if ( m_clientWindow
->OS2GetOldWndProc() )
194 m_clientWindow
->UnsubclassWin();
196 m_clientWindow
->SetHWND(0);
197 delete m_clientWindow
;
201 void wxMDIParentFrame::InternalSetMenuBar()
205 HMENU subMenu = GetSubMenu((HMENU) m_windowMenu, 0);
207 m_parentFrameActive = TRUE;
209 InsertWindowMenu(GetClientWindow(), m_hMenu, subMenu);
213 void wxMDIParentFrame::OnSize(wxSizeEvent
& event
)
217 if ( GetClientWindow() )
220 GetClientSize(&width, &height);
222 GetClientWindow()->SetSize(0, 0, width, height);
227 // Returns the active MDI child window
228 wxMDIChildFrame
*wxMDIParentFrame::GetActiveChild() const
230 HWND hWnd
= 0; // TODO: (HWND)::SendMessage(GetWinHwnd(GetClientWindow()),
231 // WM_MDIGETACTIVE, 0, 0L);
235 return (wxMDIChildFrame
*)wxFindWinFromHandle((WXHWND
) hWnd
);
238 // Create the client window class (don't Create the window, just return a new
240 wxMDIClientWindow
*wxMDIParentFrame::OnCreateClient()
242 return new wxMDIClientWindow
;
245 // Responds to colour changes, and passes event on to children.
246 void wxMDIParentFrame::OnSysColourChanged(wxSysColourChangedEvent
& event
)
248 if ( m_clientWindow
)
250 m_clientWindow
->SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
));
251 m_clientWindow
->Refresh();
257 // ---------------------------------------------------------------------------
259 // ---------------------------------------------------------------------------
261 void wxMDIParentFrame::Cascade()
263 // TODO: ::SendMessage(GetWinHwnd(GetClientWindow()), WM_MDICASCADE, 0, 0);
266 // TODO: add a direction argument (hor/vert)
267 void wxMDIParentFrame::Tile()
269 // TODO: ::SendMessage(GetWinHwnd(GetClientWindow()), WM_MDITILE, MDITILE_HORIZONTAL, 0);
272 void wxMDIParentFrame::ArrangeIcons()
274 // TODO: ::SendMessage(GetWinHwnd(GetClientWindow()), WM_MDIICONARRANGE, 0, 0);
277 void wxMDIParentFrame::ActivateNext()
279 // TODO: ::SendMessage(GetWinHwnd(GetClientWindow()), WM_MDINEXT, 0, 0);
282 void wxMDIParentFrame::ActivatePrevious()
284 // TODO: ::SendMessage(GetWinHwnd(GetClientWindow()), WM_MDINEXT, 0, 1);
287 // ---------------------------------------------------------------------------
288 // the MDI parent frame window proc
289 // ---------------------------------------------------------------------------
291 MRESULT
wxMDIParentFrame::OS2WindowProc(WXUINT message
,
296 bool processed
= FALSE
;
304 WXWORD state, minimized;
306 UnpackActivate(wParam, lParam, &state, &minimized, &hwnd);
308 processed = HandleActivate(state, minimized != 0, hwnd);
316 UnpackCommand(wParam, lParam, &id, &hwnd, &cmd);
318 (void)HandleCommand(id, cmd, hwnd);
320 // even if the frame didn't process it, there is no need to try it
321 // once again (i.e. call wxFrame::HandleCommand()) - we just dud it,
322 // so pretend we processed the message anyhow
326 // always pass this message DefFrameProc(), otherwise MDI menu
327 // commands (and sys commands - more surprizingly!) won't work
328 MSWDefWindowProc(message, wParam, lParam);
332 m_clientWindow = OnCreateClient();
333 // Uses own style for client style
334 if ( !m_clientWindow->CreateClient(this, GetWindowStyleFlag()) )
336 wxLogMessage(_("Failed to create MDI parent frame."));
347 // we erase background ourselves
355 UnpackMenuSelect(wParam, lParam, &item, &flags, &hmenu);
357 if ( m_parentFrameActive )
359 processed = HandleMenuSelect(item, flags, hmenu);
361 else if (m_currentChild)
363 processed = m_currentChild->
364 HandleMenuSelect(item, flags, hmenu);
370 // as we don't (usually) resize the MDI client to exactly fit the
371 // client area (we put it below the toolbar, above statusbar &c),
372 // we should not pass this one to DefFrameProc
377 rc
= wxFrame::OS2WindowProc(message
, wParam
, lParam
);
382 bool wxMDIParentFrame::HandleActivate(int state
, bool minimized
, WXHWND activate
)
384 bool processed
= FALSE
;
388 if ( wxWindow::HandleActivate(state, minimized, activate) )
394 // If this window is an MDI parent, we must also send an OnActivate message
395 // to the current child.
396 if ( (m_currentChild != NULL) &&
397 ((state == WA_ACTIVE) || (state == WA_CLICKACTIVE)) )
399 wxActivateEvent event(wxEVT_ACTIVATE, TRUE, m_currentChild->GetId());
400 event.SetEventObject( m_currentChild );
401 if ( m_currentChild->GetEventHandler()->ProcessEvent(event) )
408 bool wxMDIParentFrame::HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND hwnd
)
410 // In case it's e.g. a toolbar.
413 wxWindow
*win
= wxFindWinFromHandle(hwnd
);
415 return FALSE
; // Need to get wxWindow for OS/2 up to date: win->OS2Command(cmd, id);
418 // is it one of standard MDI commands?
426 case IDM_WINDOWCASCADE:
428 wParam = MDITILE_SKIPDISABLED;
431 case IDM_WINDOWTILEHOR:
432 wParam |= MDITILE_HORIZONTAL;
435 case IDM_WINDOWTILEVERT:
437 wParam = MDITILE_VERTICAL;
439 wParam |= MDITILE_SKIPDISABLED;
442 case IDM_WINDOWICONS:
443 msg = WM_MDIICONARRANGE;
456 // TODO: ::SendMessage(GetWinHwnd(GetClientWindow()), msg, wParam, 0);
461 // FIXME VZ: what does this test do??
464 return FALSE
; // Get WndProc to call default proc
467 if ( IsMdiCommandId(id
) )
469 wxWindowList::Node
* node
= GetChildren().GetFirst();
472 wxWindow
* child
= node
->GetData();
473 if ( child
->GetHWND() )
475 long childId
= wxGetWindowId(child
->GetHWND());
476 if (childId
== (long)id
)
478 // TODO: ::SendMessage( GetWinHwnd(GetClientWindow()),
480 // (WPARAM)child->GetHWND(), 0);
484 node
= node
->GetNext();
487 else if ( m_parentFrameActive
)
489 return ProcessCommand(id
);
491 else if ( m_currentChild
)
493 return m_currentChild
->HandleCommand(id
, cmd
, hwnd
);
497 // this shouldn't happen because it means that our messages are being
498 // lost (they're not sent to the parent frame nor to the children)
499 wxFAIL_MSG(wxT("MDI parent frame is not active, "
500 "yet there is no active MDI child?"));
506 MRESULT
wxMDIParentFrame::OS2DefWindowProc(WXUINT message
,
511 if ( GetClientWindow() )
512 clientWnd
= GetClientWindow()->GetHWND();
516 // TODO: return DefFrameProc(GetHwnd(), (HWND)clientWnd, message, wParam, lParam);
520 bool wxMDIParentFrame::OS2TranslateMessage(WXMSG
* msg
)
524 if ( m_currentChild && m_currentChild->GetHWND() &&
525 m_currentChild->OS2TranslateMessage(msg) )
530 if ( m_acceleratorTable.Translate(this, msg) )
535 if ( pMsg->message == WM_KEYDOWN || pMsg->message == WM_SYSKEYDOWN )
537 if ( ::TranslateMDISysAccel(GetWinHwnd(GetClientWindow()), pMsg))
544 // ===========================================================================
546 // ===========================================================================
548 wxMDIChildFrame::wxMDIChildFrame()
552 bool wxMDIChildFrame::Create(wxMDIParentFrame
*parent
,
554 const wxString
& title
,
558 const wxString
& name
)
560 m_hDefaultIcon
= (WXHICON
)(wxSTD_MDICHILDFRAME_ICON
? wxSTD_MDICHILDFRAME_ICON
561 : wxDEFAULT_MDICHILDFRAME_ICON
);
568 m_windowId
= (int)NewControlId();
572 parent
->AddChild(this);
586 mcs.szClass = wxMDIChildFrameClassName;
588 mcs.hOwner = wxGetInstance();
592 mcs.x = CW_USEDEFAULT;
597 mcs.y = CW_USEDEFAULT;
602 mcs.cx = CW_USEDEFAULT;
607 mcs.cy = CW_USEDEFAULT;
609 DWORD msflags = WS_OVERLAPPED | WS_CLIPCHILDREN;
610 if (style & wxMINIMIZE_BOX)
611 msflags |= WS_MINIMIZEBOX;
612 if (style & wxMAXIMIZE_BOX)
613 msflags |= WS_MAXIMIZEBOX;
614 if (style & wxTHICK_FRAME)
615 msflags |= WS_THICKFRAME;
616 if (style & wxSYSTEM_MENU)
617 msflags |= WS_SYSMENU;
618 if ((style & wxMINIMIZE) || (style & wxICONIZE))
619 msflags |= WS_MINIMIZE;
620 if (style & wxMAXIMIZE)
621 msflags |= WS_MAXIMIZE;
622 if (style & wxCAPTION)
623 msflags |= WS_CAPTION;
629 DWORD Return
= 0; // SendMessage(GetWinHwnd(parent->GetClientWindow()),
630 // WM_MDICREATE, 0, (LONG)(LPSTR)&mcs);
631 m_hWnd
= (WXHWND
)Return
;
634 wxAssociateWinWithHandle((HWND
) GetHWND(), this);
636 // VZ: what's this? an act of piracy?
637 //SetWindowLong(GetHwnd(), 0, (long)this);
639 wxModelessWindows
.Append(this);
643 wxMDIChildFrame::~wxMDIChildFrame()
648 // Set the client size (i.e. leave the calculation of borders etc.
650 void wxMDIChildFrame::DoSetClientSize(int width
, int height
)
652 HWND hWnd
= GetHwnd();
657 ::GetClientRect(hWnd, &rect);
660 GetWindowRect(hWnd, &rect2);
662 // Find the difference between the entire window (title bar and all)
663 // and the client area; add this to the new client size to move the
665 int actual_width = rect2.right - rect2.left - rect.right + width;
666 int actual_height = rect2.bottom - rect2.top - rect.bottom + height;
671 GetStatusBar()->GetSize(&sx, &sy);
676 point.x = rect2.left;
679 // If there's an MDI parent, must subtract the parent's top left corner
680 // since MoveWindow moves relative to the parent
681 wxMDIParentFrame *mdiParent = (wxMDIParentFrame *)GetParent();
682 ::ScreenToClient((HWND) mdiParent->GetClientWindow()->GetHWND(), &point);
684 MoveWindow(hWnd, point.x, point.y, actual_width, actual_height, (BOOL)TRUE);
686 wxSizeEvent event(wxSize(width, height), m_windowId);
687 event.SetEventObject( this );
688 GetEventHandler()->ProcessEvent(event);
692 void wxMDIChildFrame::DoGetPosition(int *x
, int *y
) const
697 GetWindowRect(GetHwnd(), &rect);
702 // Since we now have the absolute screen coords,
703 // if there's a parent we must subtract its top left corner
704 wxMDIParentFrame *mdiParent = (wxMDIParentFrame *)GetParent();
705 ::ScreenToClient((HWND) mdiParent->GetClientWindow()->GetHWND(), &point);
712 void wxMDIChildFrame::InternalSetMenuBar()
717 wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent();
719 HMENU subMenu = GetSubMenu((HMENU)parent->GetWindowMenu(), 0);
721 InsertWindowMenu(parent->GetClientWindow(), m_hMenu, subMenu);
723 parent->m_parentFrameActive = FALSE;
727 // ---------------------------------------------------------------------------
729 // ---------------------------------------------------------------------------
731 void wxMDIChildFrame::Maximize(bool maximize
)
733 wxMDIParentFrame
*parent
= (wxMDIParentFrame
*)GetParent();
736 if ( parent && parent->GetClientWindow() )
738 ::SendMessage(GetWinHwnd(parent->GetClientWindow()),
739 maximize ? WM_MDIMAXIMIZE : WM_MDIRESTORE,
740 (WPARAM)GetHwnd(), 0);
745 void wxMDIChildFrame::Restore()
749 wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent();
750 if ( parent && parent->GetClientWindow() )
752 ::SendMessage(GetWinHwnd(parent->GetClientWindow()), WM_MDIRESTORE,
753 (WPARAM) GetHwnd(), 0);
758 void wxMDIChildFrame::Activate()
762 wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent();
763 if ( parent && parent->GetClientWindow() )
765 ::SendMessage(GetWinHwnd(parent->GetClientWindow()), WM_MDIACTIVATE,
766 (WPARAM) GetHwnd(), 0);
771 // ---------------------------------------------------------------------------
772 // MDI window proc and message handlers
773 // ---------------------------------------------------------------------------
775 MRESULT
wxMDIChildFrame::OS2WindowProc(WXUINT message
,
780 bool processed
= FALSE
;
790 UnpackCommand((WXWPARAM)wParam, (WXLPARAM)lParam,
793 processed = HandleCommand(id, cmd, (WXHWND)hwnd);
797 case WM_GETMINMAXINFO:
798 // let the default window proc calculate the size of MDI children
799 // frames because it is based on the size of the MDI client window,
800 // not on the values specified in wxWindow m_min/max variables
801 return MSWDefWindowProc(message, wParam, lParam);
806 WXHWND hwndAct, hwndDeact;
807 UnpackMDIActivate(wParam, lParam, &act, &hwndAct, &hwndDeact);
809 processed = HandleMDIActivate(act, hwndAct, hwndDeact);
814 // must pass WM_MOVE to DefMDIChildProc() to recalculate MDI client
815 // scrollbars if necessary
820 // must pass WM_SIZE to DefMDIChildProc(), otherwise many weird
822 MSWDefWindowProc(message, wParam, lParam);
826 // DefMDIChildProc handles SC_{NEXT/PREV}WINDOW here, so pass it
827 // the message (the base class version does not)
828 return MSWDefWindowProc(message, wParam, lParam);
830 case WM_WINDOWPOSCHANGING:
831 processed = HandleWindowPosChanging((LPWINDOWPOS)lParam);
836 rc
= wxFrame::OS2WindowProc(message
, wParam
, lParam
);
841 bool wxMDIChildFrame::HandleSize(int x
, int y
, WXUINT id
)
843 HWND hwnd
= GetHwnd();
845 if ( !hwnd
|| hwnd
== invalidHandle
)
866 // forward WM_SIZE to status bar control
867 #if wxUSE_NATIVE_STATUSBAR
868 if (m_frameStatusBar && m_frameStatusBar->IsKindOf(CLASSINFO(wxStatusBar95)))
870 wxSizeEvent event(wxSize(x, y), m_frameStatusBar->GetId());
871 event.SetEventObject( m_frameStatusBar );
873 ((wxStatusBar95 *)m_frameStatusBar)->OnSize(event);
875 #endif // wxUSE_NATIVE_STATUSBAR
880 return wxWindow::HandleSize(x, y, id);
890 bool wxMDIChildFrame::HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND hwnd
)
892 // In case it's e.g. a toolbar.
895 wxWindow
*win
= wxFindWinFromHandle(hwnd
);
897 // Fix dependent stuff return win->OS2Command(cmd, id);
900 if (wxCurrentPopupMenu
)
902 wxMenu
*popupMenu
= wxCurrentPopupMenu
;
903 wxCurrentPopupMenu
= NULL
;
904 // Fix dependent stuff if (popupMenu->OS2Command(cmd, id))
908 if (GetMenuBar() && GetMenuBar()->FindItem(id
))
919 bool wxMDIChildFrame::HandleMDIActivate(long WXUNUSED(activate
),
923 wxMDIParentFrame
*parent
= (wxMDIParentFrame
*)GetParent();
929 if ( m_hWnd
== hwndAct
)
932 parent
->m_currentChild
= this;
934 HMENU child_menu
= (HMENU
)GetWinMenu();
937 parent
->m_parentFrameActive
= FALSE
;
939 menuToSet
= child_menu
;
942 else if ( m_hWnd
== hwndDeact
)
944 wxASSERT_MSG( parent
->m_currentChild
== this,
945 wxT("can't deactivate MDI child which wasn't active!") );
948 parent
->m_currentChild
= NULL
;
950 HMENU parent_menu
= (HMENU
)parent
->GetWinMenu();
953 parent
->m_parentFrameActive
= TRUE
;
955 menuToSet
= parent_menu
;
960 // we have nothing to with it
966 HMENU subMenu
= 0; // TODO: GetSubMenu((HMENU) parent->GetWindowMenu(), 0);
968 MDISetMenu(parent
->GetClientWindow(), menuToSet
, subMenu
);
971 wxActivateEvent
event(wxEVT_ACTIVATE
, activated
, m_windowId
);
972 event
.SetEventObject( this );
974 return GetEventHandler()->ProcessEvent(event
);
977 bool wxMDIChildFrame::HandleWindowPosChanging(void *pos
)
979 // WINDOWPOS *lpPos = (WINDOWPOS *)pos;
983 // ---------------------------------------------------------------------------
984 // MDI specific message translation/preprocessing
985 // ---------------------------------------------------------------------------
987 MRESULT
wxMDIChildFrame::OS2DefWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
991 return DefMDIChildProc(GetHwnd(),
992 (UINT)message, (WPARAM)wParam, (LPARAM)lParam);
997 bool wxMDIChildFrame::OS2TranslateMessage(WXMSG
* msg
)
999 return m_acceleratorTable
.Translate(GetParent()->GetHWND(), msg
);
1002 // ---------------------------------------------------------------------------
1004 // ---------------------------------------------------------------------------
1006 void wxMDIChildFrame::OS2DestroyWindow()
1008 // get wxWindow up to date OS2DetachWindowMenu();
1009 invalidHandle
= GetHwnd();
1011 wxMDIParentFrame
*parent
= (wxMDIParentFrame
*)GetParent();
1013 // Must make sure this handle is invalidated (set to NULL) since all sorts
1014 // of things could happen after the child client is destroyed, but before
1015 // the wxFrame is destroyed.
1017 HWND oldHandle
= (HWND
)GetHWND();
1018 // TODO: SendMessage(GetWinHwnd(parent->GetClientWindow()), WM_MDIDESTROY,
1019 // (WPARAM)oldHandle, 0);
1024 // TODO: ::DestroyMenu((HMENU) m_hMenu);
1030 // Change the client window's extended style so we don't get a client edge
1031 // style when a child is maximised (a double border looks silly.)
1032 bool wxMDIChildFrame::ResetWindowStyle(void *vrect
)
1037 // ===========================================================================
1038 // wxMDIClientWindow: the window of predefined (by Windows) class which
1039 // contains the child frames
1040 // ===========================================================================
1042 bool wxMDIClientWindow::CreateClient(wxMDIParentFrame
*parent
, long style
)
1044 m_backgroundColour
= wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
);
1048 CLIENTCREATESTRUCT ccs;
1049 m_windowStyle = style;
1052 ccs.hWindowMenu = (HMENU)parent->GetWindowMenu();
1053 ccs.idFirstChild = wxFIRST_MDI_CHILD;
1055 DWORD msStyle = WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN;
1056 if ( style & wxHSCROLL )
1057 msStyle |= WS_HSCROLL;
1058 if ( style & wxVSCROLL )
1059 msStyle |= WS_VSCROLL;
1061 #if defined(__WIN95__)
1062 DWORD exStyle = WS_EX_CLIENTEDGE;
1068 m_hWnd = (WXHWND)::CreateWindowEx
1078 (LPSTR)(LPCLIENTCREATESTRUCT)&ccs);
1081 wxLogLastError("CreateWindowEx(MDI client)");
1086 SubclassWin(m_hWnd);
1092 // Explicitly call default scroll behaviour
1093 void wxMDIClientWindow::OnScroll(wxScrollEvent
& event
)
1095 // Note: for client windows, the scroll position is not set in
1096 // WM_HSCROLL, WM_VSCROLL, so we can't easily determine what
1097 // scroll position we're at.
1098 // This makes it hard to paint patterns or bitmaps in the background,
1099 // and have the client area scrollable as well.
1101 if ( event
.GetOrientation() == wxHORIZONTAL
)
1102 m_scrollX
= event
.GetPosition(); // Always returns zero!
1104 m_scrollY
= event
.GetPosition(); // Always returns zero!
1109 // ---------------------------------------------------------------------------
1110 // non member functions
1111 // ---------------------------------------------------------------------------
1113 static void MDISetMenu(wxWindow
*win
, HMENU hmenuFrame
, HMENU hmenuWindow
)
1117 ::SendMessage(GetWinHwnd(win), WM_MDISETMENU,
1118 (WPARAM)hmenuFrame, (LPARAM)hmenuWindow);
1119 // update menu bar of the parent window
1120 wxWindow *parent = win->GetParent();
1121 wxCHECK_RET( parent, wxT("MDI client without parent frame? weird...") );
1123 ::DrawMenuBar(GetWinHwnd(parent));
1127 static void InsertWindowMenu(wxWindow
*win
, WXHMENU menu
, HMENU subMenu
)
1130 // Try to insert Window menu in front of Help, otherwise append it.
1131 HMENU hmenu = (HMENU)menu;
1132 int N = GetMenuItemCount(hmenu);
1133 bool success = FALSE;
1134 for ( int i = 0; i < N; i++ )
1137 int chars = GetMenuString(hmenu, i, buf, WXSIZEOF(buf), MF_BYPOSITION);
1140 wxLogLastError(wxT("GetMenuString"));
1145 if ( wxStripMenuCodes(wxString(buf)).IsSameAs(wxT("Help")) )
1148 ::InsertMenu(hmenu, i, MF_BYPOSITION | MF_POPUP | MF_STRING,
1149 (UINT)subMenu, wxT("&Window"));
1156 ::AppendMenu(hmenu, MF_POPUP, (UINT)subMenu, wxT("&Window"));
1158 MDISetMenu(win, hmenu, subMenu);
1162 static void UnpackMDIActivate(WXWPARAM wParam
, WXLPARAM lParam
,
1163 WXWORD
*activate
, WXHWND
*hwndAct
, WXHWND
*hwndDeact
)
1166 *hwndAct
= (WXHWND
)lParam
;
1167 *hwndDeact
= (WXHWND
)wParam
;