0
我有问题,MFC的(VC++)的MoveWindow()方法,我的规格是:MFC的的MoveWindow(INT X,诠释Y,诠释宽度,INT高度,FALSE)引起闪烁问题
- .NET运行库3.5
- VS 2008
- 的Windows XP
我通过的MoveWindow显示图像()方法,它首先显示的图像,然后根据传递的参数进行调整。在调整过程中会出现较小的(可见的)闪烁效应。我猜这个问题是由于MoveWindow方法。请建议我最新的错误。如果您需要更多信息,请告诉我。
**代码更新日期:2011年9月7日
void CTMLead::ResizeWndToRatio(float fHeight, float fWidth)
{
CPoint TopLeft;
float Width;
float Height;
float Ratio;
int Cx;
int Cy;
CString tempFileName;
tempFileName = m_strFilename;
// Should we use the current window dimensions?
if((fHeight <= 0) || (fWidth <= 0))
{
fHeight = (float)m_iHeight;
fWidth = (float)m_iWidth;
}
ASSERT((fHeight > 0) && (fWidth > 0));
if((fHeight <= 0) || (fWidth <= 0)) return;
// Compute the aspect ratio of the current viewport
Ratio = fHeight/fWidth;
// Find the center point of the maximum viewing area
Cx = (m_rcMax.right/2) + m_rcMax.left;
Cy = (m_rcMax.bottom/2) + m_rcMax.top;
// If we use the maximum width allowed, is the height still small
// enough to fit on the screen?
if((m_rcMax.right * Ratio) < m_rcMax.bottom)
{
// Use the full width allowed and adjust the height
Width = (float)m_rcMax.right;
Height = Width * Ratio;
}
else
{
// Use the maximum height available and adjust the width
Height = (float)m_rcMax.bottom;
Width = Height/Ratio;
}
// Calculate the new coordinates of the upper left corner
TopLeft.x = Cx - (ROUND(Width)/2);
TopLeft.y = Cy - (ROUND(Height)/2);
// Update the size and offset
m_iLeft = TopLeft.x;
m_iTop = TopLeft.y;
m_iWidth = ROUND(Width);
m_iHeight = ROUND(Height);
m_fImageWidth=m_iWidth;
m_fImageHeight=m_iHeight;
SetDstRect(0.0f, 0.0f, m_fImageWidth, m_fImageHeight);
MoveWindow (m_iLeft, m_iTop, m_iWidth, m_iHeight, FALSE);
}
感谢,
阿里
我在mouseClick上使用MoveWindow。我自己没有绘制图像,我有.tiff和.png图像。所以,我认为在双缓冲中对我来说不起作用。你能帮助代码如何玩WM_CLIPSIBLINGS和WM_CLIPCHILDREN?在此先感谢.. -Ali – Ali
您正在将图像绘制到某物上,您说'我正在通过MoveWindow()显示图像“,但这没有任何意义。您需要先解释您如何绘制或显示图像。 – Roel
感谢您的回复..我已经发布了上面包含MoveWindow方法的代码。我是MFC新手,正在开发一个现有的代码,所以我对背景知之甚少。我的调试显示MoveWindow()方法显示图像(tiff/png)。图像切换时会出现闪烁问题。请指导我最新的错误...谢谢你。 – Ali