• 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();
        }
    }
  • 相关阅读:
    hashlib模块
    configparser模块
    xml模块和shelve模块
    json与pickle模块
    3/30
    os模块
    sys模块
    shutil模块
    random模块
    2月书单《编码隐匿在计算机软硬件背后的语言》 13-16章
  • 原文地址:https://www.cnblogs.com/2018shawn/p/12205429.html
Copyright © 2020-2023  润新知