码迷,mamicode.com
首页 > 其他好文 > 详细

GDI+ 双缓存 和 刷新桌面(F5)

时间:2016-11-23 20:14:37      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:pen   dbi   import   soc   pre   _id   window   important   color   

GDI+双缓存

    POINT currentPoint;
    GetCursorPos(&currentPoint);
    HWND hWnd = ::GetDesktopWindow();
    int nWidth = GetSystemMetrics(SM_CXSCREEN);
    int nHeight = GetSystemMetrics(SM_CYSCREEN);
    RECT r;
    GetWindowRect(hWnd, &r);
    Bitmap bmp(nWidth, nHeight);
    Graphics mem_graphic(&bmp);
    mem_graphic.SetSmoothingMode(Gdiplus::SmoothingModeHighQuality);
    static bool bChange = false;
    Pen p(bChange ? Color(0, 255, 0) : Color(255, 0, 0));
    bChange = !bChange;
    Rect rt(currentPoint.x - 10, currentPoint.y - 10, 20, 20);
    mem_graphic.DrawEllipse(&p, rt);
    mem_graphic.DrawLine(&p,rt.X, currentPoint.y, rt.X + rt.Width, currentPoint.y);
    mem_graphic.DrawLine(&p,currentPoint.x, rt.Y, currentPoint.x , rt.Y + rt.Height);
    Rect rt_small(currentPoint.x - 5, currentPoint.y - 5, 10, 10);
    mem_graphic.DrawEllipse(&p, rt_small);

    HDC hDC= ::GetDC(hWnd);
    Graphics graphics(hDC);
    CachedBitmap cachedBmp(&bmp,&graphics);   //important
    graphics.DrawCachedBitmap(&cachedBmp,0,0);

刷新桌面(F5)

        ::SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST | SHCNF_FLUSH, 0, 0);

 

GDI+ 双缓存 和 刷新桌面(F5)

标签:pen   dbi   import   soc   pre   _id   window   important   color   

原文地址:http://www.cnblogs.com/john-h/p/6094716.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!