Benutzer mit den meisten Antworten
Embed a CMDIFrameWnd in a CDialog

Frage
-
Hi,
I want to embed a CMDIFrameWnd in a CDialog.
CMDIFrameWnd supports docking for child windows, and i need this functionality in a modal dialog.
I can create a CMDIFrameWnd inside OnInitDialog, but CMDIFrameWnd::OnCreateClient complains that my CMDIFrameWnd has no menu, and I don't know how I should supply it. Actually, I don't want a menu either; I just want to have docking tabs in a CDialog.
I am using something like this:
CMDIFrameWnd *frameWnd = new CMDIFrameWnd; CRect rect = new CRect(10,10,200,200); DWORD dwStyle = WS_EX_CLIENTEDGE | WS_CHILD; BOOL rc = frameWnd->Create(null,"test1",dwStyle,rect,this,NULL,0,NULL); frameWnd->ShowWindow(SW_SHOW);
I KNOW that a CMDIFrameWnd is really meant to be an applications main window, but i want to use BCGSoft's BCGControlBar library, and it needs a CMDIFrameWnd as container for docking tabs. And again, I want them in a dialog.
And: I need a CMDIFrameWnd, not a CFrameWnd.
Antworten
-
- Als Antwort vorgeschlagen Martin RichterModerator Mittwoch, 6. April 2011 13:34
- Als Antwort markiert Peter Schmeichel Mittwoch, 6. April 2011 13:42
Alle Antworten
-
The application that i'm maintaining has its own framework, and forces me to use a dialog here.
I mentioned that i did not succeed to supply a menu to the CMDIFrameWnd.
I tried it programmatically (CMenu), and declaratively (Resource), but i'm missing the right event or the right parameter to pass the menu to MFC.
I can't pass it before I call frameWnd->Create, because the window isn't yet created, and i cant't pass it while the window is created, because i didn't succeed in catching a suitable event.
-
1. This is a German forum. Please continue the discussion in German.
You also find english ones under http://social.msdn.microsoft.com/Forums/en-US
2. What happens if you add it by a resource? What assert do you get?
Martin Richter -- MVP for VC++ [Germany] -- http://blog.m-ri.de -
Der Stackdump sieht etwa so aus:
CFrameWnd::Create CWnd::CreateEx User32... CWnd::WindowProc CWnd::OnWndMsg CFrameWnd::OnCreate CFrameWnd::OnCreateHelper CMDIFrameWnd::OnCreateClient BOOL CMDIFrameWnd::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext*) { CMenu* pMenu = NULL; if (m_hMenuDefault == NULL) { // default implementation for MFC V1 backward compatibility pMenu = GetMenu(); ASSERT(pMenu != NULL);
-
- Als Antwort vorgeschlagen Martin RichterModerator Mittwoch, 6. April 2011 13:34
- Als Antwort markiert Peter Schmeichel Mittwoch, 6. April 2011 13:42
-
OK. Ich habe CFrameWnd::Create überschrieben und dort ein Menü aus der Resourcedatei angegeben. Jetzt läuft es.
class CDockFrameWnd : public CFrameWnd { ... virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, LPCTSTR lpszMenuName, DWORD dwExStyle, CCreateContext* pContext); }; BOOL CDockFrameWnd::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, LPCTSTR lpszMenuName, DWORD dwExStyle, CCreateContext* pContext) { lpszMenuName = MAKEINTRESOURCE(IDR_MENU1); return CFrameWnd::Create(lpszClassName,lpszWindowName,dwStyle,rect,pParentWnd,lpszMenuName,dwExStyle,pContext); } BOOL CTest4Dlg::OnInitDialog() { CRect rectClient; GetClientRect (rectClient); CString strMyClass = AfxRegisterWndClass(CS_VREDRAW | CS_HREDRAW, ::LoadCursor(NULL, IDC_ARROW), (HBRUSH) ::GetStockObject(GRAY_BRUSH), ::LoadIcon(NULL, IDI_APPLICATION)); CDockFrameWnd *frameWnd = new CDockFrameWnd; CRect rect = new CRect(10,100,rectClient.right - 50,380); DWORD dwStyle = WS_EX_CLIENTEDGE | WS_CHILD; BOOL rc = frameWnd->Create(strMyClass,"test1",dwStyle,rect,this,NULL,0,NULL); frameWnd->ShowWindow(SW_SHOW); }