zoukankan      html  css  js  c++  java
  • DrawDragRect函数在窗口显示异常

    DrawDragRect函数在窗口显示异常:

    父窗口风格设置异常;

        SetWindowLongPtr(m_hWnd,
            GWL_EXSTYLE,
            GetWindowLong(m_hWnd, GWL_EXSTYLE) | WS_EX_LAYERED);

    去除这段代码就OK显示正常了

    下面附上画选中矩形框的代码;

    void OnLButtonDown(UINT nFlags, CPoint point)
    {
            SetCapture();
            m_bDragging = true;
            m_lastPoint = point;
            CDC *pDC = GetDC();
            CRect rect(point, point);
            pDC->DrawDragRect(&rect, CSize(1, 1), NULL, CSize(1, 1), NULL, NULL);
            m_lastRect = rect;
            ReleaseDC(pDC);
    }
    void OnMouseMove(UINT nFlags, CPoint point)
    {    
        if (m_bDragging && GetCapture() == this)
        {
            CDC *pDC = GetDC();
            CSize curSize(1,1), lastSize;
            CRect newRect(m_lastPoint, point);
            newRect.NormalizeRect();
            lastSize.cx = 1;
            lastSize.cy = 1;
            pDC->DrawDragRect(newRect, curSize, m_lastRect, lastSize);
            ReleaseDC(pDC);
            m_lastRect = newRect; 
        }
    }
    
    void OnLButtonUp(UINT nFlags, CPoint point)
    {
        if (m_bDragging && GetCapture() == this)
        {
            m_bDragging = false;
            CDC *pDC = GetDC();
            CRect rect(0, 0, 0, 0);
            pDC->DrawDragRect(rect, CSize(1, 1), &m_lastRect, CSize(1, 1), NULL, NULL);
            ReleaseDC(pDC);
            //Invalidate();
            ReleaseCapture();
        }
    }
  • 相关阅读:
    generator
    JS 中 apply 、call 、bind的详解
    前端面试题(24-js)
    JS原型链深入了解
    Java12新特性
    Java11-ZGC
    Java11新特性
    Java10新特性
    Java9新特性
    CF1385E【Directing Edges】 (拓扑排序)
  • 原文地址:https://www.cnblogs.com/2018shawn/p/12205429.html
Copyright © 2011-2022 走看看