Solved

non-MFC MDI frame & MFC child

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Login Script to Copy Folders 12 35
Include multiple hostnames in this command? 3 55
Folder Comparison 12 54
MaxSpan challenge 9 96
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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

778 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