Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CDialog to CView

Tags:

mfc

cdialog

cview

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.

like image 852
user1173240 Avatar asked Jan 20 '26 01:01

user1173240


1 Answers

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.
like image 198
xMRi Avatar answered Jan 23 '26 01:01

xMRi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!