ChildView.cpp; (class CChildView : public CWnd, OnPaint() is here)
MainFrm.cpp; (class CMainFrame : public CFrameWnd)
ImagePro.cpp;(class CImageProApp : public CWinApp)
I also create CModalLessDlg using the dialog template, which is defined in ModalLessDlg.cpp and ModalLessDlg.h
In the ModalLessDlg.cpp, I want to press the "Begin" button to send the "view" a message
you can realize it like this:
1. in ChildView.cpp
#include "ModalLessDlg.h"
void CChildView::OnModalLess() // show the modalless dialog
{
CModalLessDlg* instance = new CModalLessDlg(this);
instance->Create(CModalLessDlg::IDD,this);
instance->PARENT = this;
instance->ShowWindow(1);
}
2. in ModalLessDlg.h
#include "ChildView.h" public: CChildView *PARENT;
3. in ChildView.h
public: void setDisplayText(CString src); private: CString displayText;
4. in ChildView.cpp
CChildView::CChildView(): displayText(_T("zhiguang"))
{
}
void CChildView::setDisplayText(CString src)
{
displayText=src;
Invalidate(TRUE);
}
void CChildView::OnPaint() // show different results of image
{
CPaintDC dc(this); // device context for painting
CRect rect;
GetClientRect (&rect);
dc.DrawText (displayText, -1, &rect,DT_SINGLELINE | DT_CENTER | DT_VCENTER);
}
5. in ModalLessDlg.cpp
void CModalLessDlg::OnBegin() //
{
CString str_sent="OnBegin is running!";
PARENT->setDisplayText(str_sent);
}
that is all.
it is using ChildView as one parameter to construct the modaless dialog, then you can easily use the ChildView and its members to change the client area.




