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();
        }
    }
  • 相关阅读:
    webstorm9.0.3 注册码
    SpringMVC 文件上传下载
    Nginx解决post请求405问题
    nginx配置Strict Transport Security
    MySQL修改max_allowed_packet
    ELK批量删除索引
    ELK出现unassigned_shards查看及删除
    Nagios监控mysql主从复制
    Linux DNS原理简介及配置
    root密码重置(Centos 7)
  • 原文地址:https://www.cnblogs.com/2018shawn/p/12205429.html
Copyright © 2011-2022 走看看