首页 | 社区 | 博客 | 招聘 | 文章 | 新闻 | 下载 | 读书 | 代码
亲,您未登录哦! 登录 | 注册

一个很COOL的对话框弹出效果

打印文章

分享到:
内容:
//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[5];
pt[0] = CPoint(transition.left, transition.top);
pt[1] = CPoint(transition.right,transition.top);
pt[2] = CPoint(transition.right,transition.bottom);
pt[3] = CPoint(transition.left, transition.bottom);
pt[4] = 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);
        about.DoModal();
______________________________________________________________
//如果要用于主窗口,则将上OnCreate和DestoryWindow改为主窗口的
//变量m_rectFrom也改为主窗口的

//然后在APP类的dlg.DoModal();之前加入:

     CRect rc(0,0,1,1);//变出的位置
     dlg.m_rectFrom=rc; 

本栏文章均来自于互联网,版权归原作者和各发布网站所有,本站收集这些文章仅供学习参考之用。任何人都不能将这些文章用于商业或者其他目的。( Pfan.cn )

编程爱好者论坛

本栏最新文章