如何将控件传递回父对话框? [英] How to pass a control back to parent dialog?

查看:48
本文介绍了如何将控件传递回父对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个叫做CChartCtrl的类,我用它来绘制图形.

我绘制的图形位于父对话框的自定义控件"中.我有一个名为全屏"的按钮.
当我单击全屏按钮时,我将自定义"控件传递给了全屏"中的新对话框.

当我尝试还原到父对话框时,它将给我错误.

Hi,

I''ve a class called CChartCtrl which i used it to draw graphs.

The graphs that i drew is in a Custom Control in the parent dialog. I''ve a button called "Full-Screen".
When i clicked on the full screen button, I passed the Custom control to the new dialog in Full-screen.

When i tried to restore to the parent dialog, it will give me error.

CChartCtrl m_ChartCtrl; 
CFullScreen m_pFullScr; 
void CParentDialog::OnBnClickedButtonFullscr() 
{ 
        m_pFullScr.SetChartCtrl(&m_ChartCtrl); 
} 
CChartCtrl* m_maxChartCtrl; 
void CFullScreen::SetChartCtrl(CChartCtrl* ChartCtrl) 
{ 
        m_maxChartCtrl = ChartCtrl; 
}



在全屏启动对话框中:



In Full-Screen On-Init Dialog:

m_maxChartCtrl->SetParent(this);



当我单击还原"屏幕按钮时:



When I clicked the restore screen button:

CParentDlg *dlg = (CParentDlg *) this->GetParent();
dlg->SetChartCtrl(m_maxChartCtrl);


在父对话框中:


In Parent Dialog:

CChartCtrl m_ChartCtrl;

void CParentDlg::SetChartCtrl(CChartCtrl ChartCtrl)
{
	m_ChartCtrl = ChartCtrl;   // Error occurs here
}

if(m_pFullScr.DoModal() == IDOK)
{

	m_ChartCtrl.SetParent(this);
}



我会收到此错误:

错误C2582:在``CChartCtrl''中无法使用``operator =''功能

CChartCtrl派生自CWnd.
我做错什么了吗?任何帮助是极大的赞赏.谢谢.



I will receive this error:

error C2582: ''operator ='' function is unavailable in ''CChartCtrl''

CChartCtrl is derived from CWnd.
Am i doing anything wrong? Any help is greatly appreciated. Thank you.

推荐答案

您的CChartCtrl类没有副本(=)运算符.

可以通过指针或引用将现有控件传递到可以调整大小和重绘图表的全屏对话框.但这需要为控件分配一个新的父窗口,这可能会产生副作用.

解决方案是:

Your CChartCtrl class has no copy (=) operator.

It may be possible to pass the existing control by pointer or reference to the full screen dialog that can resize and redraw the chart. But that requires assignment of a new parent window to the control which may have side effects.

Solutions are:


  1. 如果常规对话框中仅包含图表而没有其他控件,则可以通过删除边框和标题并将其调整为全屏大小来将其修改为全屏显示.
  2. 使用以下方法创建新的图表现有的设置和数据.也就是说,为全屏模式创建新的图表,例如为普通视图(通过设置和数据点)创建图表.


这篇关于如何将控件传递回父对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆