内容:
//1.在实现文件中的include之后加入一个辅助函数
void WINAPI DrawWireRects(LPRECT lprcFrom, LPRECT lprcTo, UINT nMilliSecSpeed)
{
const int nNumSteps = 10;
GdiFlush();
Sleep(50); // Let the desktop window sort itself out
// if hwnd is null - "you have the CON".
HDC hDC = ::GetDC(NULL);
// Pen size, urmmm not too thick
HPEN hPen = ::CreatePen(PS_SOLID, 2, RGB(0,0,0));
int nMode = ::SetROP2(hDC, R2_NOT);
HPEN hOldPen = (HPEN) ::SelectObject(hDC, hPen);
for (int i = 0; i < nNumSteps; i++)
{
double dFraction = (double) i / (double) nNumSteps;
RECT transition;
transition.left = lprcFrom->left + (int)((lprcTo->left - lprcFrom->left) * dFraction);
transition.right = lprcFrom->right + (int)((lprcTo->right - lprcFrom->right) * dFraction);
transition.top = lprcFrom->top + (int)((lprcTo->top - lprcFrom->top) * dFraction);
transition.bottom = lprcFrom->bottom + (int)((lprcTo->bottom - lprcFrom->bottom) * dFraction);
POINT pt;
pt[0] = CPoint(transition.left, transition.top);
pt = CPoint(transition.right,transition.top);
pt = CPoint(transition.right,transition.bottom);
pt = CPoint(transition.left, transition.bottom);
pt = CPoint(transition.left, transition.top);
// We use Polyline because we can determine our own pen size
// Draw Sides
::Polyline(hDC,pt,5);
GdiFlush();
Sleep(nMilliSecSpeed);
// UnDraw Sides
::Polyline(hDC,pt,5);
GdiFlush();
}
::SetROP2(hDC, nMode);
::SelectObject(hDC, hOldPen);
::ReleaseDC(NULL,hDC);
}
//2.为About对话框加入:
CRect m_rectFrom;//成员变量
//3.在About的OnCreaet中加入:
if (!m_rectFrom.IsRectEmpty())
{
CRect rectTo(lpCreateStruct->x,lpCreateStruct->y,
lpCreateStruct->x + lpCreateStruct->cx,
lpCreateStruct->y + lpCreateStruct->cy);
DrawWireRects(m_rectFrom, rectTo, 20);
// DrawAnimatedRects(m_hWnd, IDANI_CAPTION, m_rectFrom,rectTo);
// 不要效果时
}
//在About的DestoryWindow上加入:
if (!m_rectFrom.IsRectEmpty())
{
CRect rect;
GetWindowRect(rect);
rect.DeflateRect(2,2);
DrawWireRects(rect, m_rectFrom, 20);
// DrawAnimatedRects(m_hWnd,IDANI_CAPTION, rect, m_rectFrom);
// 不要效果时
}
//激活时用:
CAboutDlg about;
m_btn.GetWindowRect(about.m_rectFrom);
&