有没有办法复制主对话框的DC [英] Is there any way to copy DC of main dialog
问题描述
我的应用程序中有三个对话框,分别是x,y和z.在作为我的主窗口的x对话框上,我正在使用其OnPaint()函数显示一些图形.另外,我在"x"上放置了一个按钮"b1".单击b1时,会弹出对话框``y'',上面带有一个``preview button''.我希望单击``preview''按钮可以打开对话框窗口``z'',该对话框具有与对话框相同的图形"x"具有.为此,我已使用bitblt将x的DC复制到z的DC.但是在``z''上,它显示打开的对话窗口y和z以及与对话框``x''的图形混合.但是我只希望窗口x的图形,没有预览打开的对话窗口``y ''和``z''.有什么方法可以复制主对话框的DC.
I have three dialogs say x,y and z in my application. On x dialog which is my main window, I am displaying some graphics using its OnPaint() function . Also I have placed a button ''b1'' on ''x'' . On click of b1, dialog ''y'' pops up which have a ''preview button'' on it .I want that clicking on ''preview'' button opens dialog window ''z'' with the same graphics that dialog ''x'' has . For doing so, I have copied DC of x to DC of z using bitblt. But on ''z'' , its showing the opened dialog windows y and z aswell mixing up with graphs of dialog ''x'' .But I want only the graphs of my window x, no preview of opened dialog windows ''y'' and ''z''. Is there any way to copy DC of my main dialog .
推荐答案
这将是结果,
如果未设置您的m_pcX ... :)
请发布
y和z的构造(实例化)行:)
It would be a result,
if your m_pcX is not set... :)
Please post
your lines of constructing (instancing) of y and z :)
假设您的z具有指向x的指针,并且有一个函数:
Assumed your z has a pointer to x and there is a function:
void x::OnDraw(CDC* pDC)
{
...
}
现在您可以将其称为您的
Now you coul call it form your
void x::OnPaint()
{
CPaintDC dc(this);
OnDraw(&dc)
}
...以及您的
...as well from your
void z::OnPaint()
{
CPaintDC dc(this);
px->OnDraw(&dc)
}
这将是没有任何DC复制的解决方案...:)
It would be a solution without any copying of DC... :)
作为替代解决方案
您可以提供x的附加构造函数:
As an alternative solution
you could provide an additional constructor of x:
x::x(const x& original, bool bHideB1 = true)
{
// copy the members here...
...
// and set a new member
m_bHideB1 = bHideB1;
}
...并扩展您的
... and extend your
BOOL x::OnInitDialog()
{
...
if (m_bHideB1) {
CWnd* pcWnd = GetDlgItem(IDC_BUTTON1);
if (pcWnd) {
pcWnd->ShowWindow(SW_HIDE);
}
}
...
}
现在您可以修改预览"反应:
Now you could modify your "preview" reaction:
void y::OnPreview()
{
x anotherX(*px); // here px is pointer to parent x dialog
anotherX.DoModal();
}
如果没有z ...类,这将是一个解决方案:)
It would be a solution without the class z... :)
这篇关于有没有办法复制主对话框的DC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!