Solved

non-MFC MDI frame & MFC child

Posted on 1998-06-12
4
441 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
  • 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now