• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

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

发布: 2007-7-14 21:11 | 作者: 佚名    | 来源: 网络转载     | 查看: 23次 | 进入软件测试论坛讨论

领测软件测试网 内容:
//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; 

延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网