Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

non-MFC MDI frame & MFC child

Posted on 1998-06-12
4
Medium Priority
?
465 Views
Last Modified: 2013-11-20
I have a non-MFC MDI application where each type of MDI child is in DLL. EXE calls exported DLL function that creates MDI child window with window procedure inside this DLL.
I have been asked to create new MDI child type using MFC. I tried to derive new window from CWnd and with some corrections it seems to work OK. (I have changed CMyWnd::DefWindowProc to call ::DefMDIChildProc)

But if I want to use document/view inside this DLL it needs the MDI child frame window to be derived from CFrameWnd and I am not able to make it working.

Is it possible at all?
0
Comment
Question by:magnezko
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 4

Expert Comment

by:piano_boxer
ID: 1317899
The frame for your views should be derived from CMDIChildWnd.
The main windows (CMainFrame) should be derived from CMDIFrameWnd.

0
 

Author Comment

by:magnezko
ID: 1317900
Main window is written using API without MFC and it is not desirable to make major changes to existing code...

0
 
LVL 2

Accepted Solution

by:
Belgarat earned 400 total points
ID: 1317901
Well... if you're going to continue with MFC-based extensions, maybe you should fool MFC with CFrameWnd instance attached to the main MDI frame window. If you attach (CWnd::Attach) the MFC object to an existing window, MFC will subclass it - as long as you will pass all messages unchanged to the previous window procedure, the application will behave the exactly same way as before.
You can put the pointer to the instance in e.g. some exported variable so the instance can be shared across another (in the future) DLLs - remember, you can Attach only one CWnd-descendant to a particular window.
It should be sufficient to Attach the CFrameWnd instance, but you have to fill CFrameWnd::m_hWndMDIClient member manually - with the handle of the MDI Client window residing in the frame. Then you should be able to create MDI child windows in the standard way.

0
 

Author Comment

by:magnezko
ID: 1317902
Great! It seems to be OK!
I had to force the newly created window to be MDI child, so I had to override PreCreateWindow function of my CFrameWnd derived class to set WS_EX_MDICHILD style and set my hClient handle as
hwndParent. (m_hWndMDIClient can't be used because it is not member of CFrameWnd but CMDIFrameWnd)

Next I overrode DefWindowProc function to call ::DefMDIChildProc.
WS_EX_MDICHILD style leads to a fault in a view creation. Somewhere in MFC code pContext parameter is loosing value of m_pNewViewClass member. So I saved correct value in LoadFramne function and restore it in OnCreate function and view is
created correctly. In addition there are some problems with main frame menu, so I had to manually set m_hMenuDefault to NULL and m_bAutoMenuEnable to FALSE.
Thanks much.

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

664 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question