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();
        }
    }
  • 相关阅读:
    Selenium库的使用
    Win10 常用快捷键
    503.下一个更大元素 II
    456.132模式
    201.数字范围按位与
    78.子集
    299.猜数字游戏
    49.字母异位词分组
    36.有效的数独
    290.单词规律
  • 原文地址:https://www.cnblogs.com/2018shawn/p/12205429.html
Copyright © 2011-2022 走看看