3

So I've an MFC based application, which is primarily derived from CDialog, with some controls etc.

For certain reasons, it needs to be hosted in another application, using a container class, which is based on CView.

So there has to be some way...of hosting this thing, made using CDialog, inside a container class, which expects the thing as a CView.

The container class is closed to me. It will expect a CView, but I can modify the dialog based application.

Is there an easy way to migrate over from CDialog based to CView based, and what would I need to look at, please. I'm not very skilled with MFC, and the question might sound vague, but it's what I have.

Any help would be appreciated...Thanks.

user1173240
  • 1,455
  • 2
  • 23
  • 50

1 Answers1

3

You can use a CFormView. That is a view supporting dialog resource templates.

The problematic code is loading and commiting the data into and from the CFormView. Views are usually controlled by a CDocument, that calls UpdateAllViews with some hints.

Your dialog functions for OnOK, OnCancel and OnInitDalog must be changed to fit into the Doc/View architecture.

  • Move the OnInitDialog code into OnInitialUpdate, but be aware that in an SDI application OnInitialUpdate might be called more than once.
  • OnOK and OnCancel must be solved by some calls and functions from the document.
xMRi
  • 14,982
  • 3
  • 26
  • 59
  • Thank you for the clarification. Could you throw more light on the second point please? I didn't quite understand that. – user1173240 Nov 18 '13 at 13:42
  • 1
    Create an application with the wizard and a CFromView... may be this will clarify things. Otherwise please ask for specific details. I don't know what to explain in more detail. – xMRi Nov 18 '13 at 14:44