Solved

non-MFC MDI frame & MFC child

Posted on 1998-06-12
4
458 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 100 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

617 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