У меня проблема с методом MFC (VC ++) MoveWindow (). Мои спецификации:
- .net Runtime 3.5
- VS 2008
- Windows XP
Я отображаю изображения с помощью метода MoveWindow (), сначала он отображает изображение, а затем корректирует его в соответствии с переданным параметром. Во время регулировки возникает незначительный (видимый) эффект мерцания. Я предполагаю, что эта проблема связана с методом MoveWindow. Пожалуйста, предложите мне, что не так. Пожалуйста, дайте мне знать, если вам нужна дополнительная информация.
** код обновлен: 07 сентября 2011
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 );
}
Спасибо
Али