zoukankan      html  css  js  c++  java
  • ::GetClientRect(HWND,&LPRECT); return 0 ?

    最近在写一个控件CMenuButton,初衷是提供设置偏移量的接口,可是ASSERT总是中断,调试发现::GetClientRect()返回的rect都是0值。
    Google了一下,原来:
    Q:“为何在OnCreate调用取出的就是0 呢 ?
    在OnInitialUpdate中是可以调用的,返回数据也是正确的 ”

    A:“OnCreate时还没创建出客户区 ”

    void CMenuButton::SetOffset(int OffsetL, int OffsetR, int OffsetTop, int OffsetBottom)
    {
        //if out of client bound, then hold it in the bound
        RECT client_rect;
        ::GetClientRect(m_hWnd, &client_rect);//返回值总是0?

        OffsetL = OffsetL<0 ? 0 : OffsetL;
        OffsetR = OffsetR<0 ? 0 : OffsetR;
        OffsetTop = OffsetTop<0 ? 0 :OffsetTop;
        OffsetBottom = OffsetBottom<0 ? 0 :OffsetBottom;

        ATLASSERT(( (OffsetL+OffsetR < client_rect.right-client_rect.left) && (OffsetTop+OffsetBottom < client_rect.bottom-client_rect.top)));

        m_nOffsetLeft = OffsetL;
        m_nOffsetRight = OffsetR;
        m_nOffsetTop = OffsetTop;
        m_nOffsetBottom = OffsetBottom;
        m_nItemWidth = client_rect.right-client_rect.left-m_nOffsetLeft-m_nOffsetRight;
        ATLASSERT(m_nItemWidth > 0);
        m_nItemHeight2 = m_nItemHeight1 = client_rect.bottom-client_rect.top-m_nOffsetBottom-m_nOffsetTop;
        ATLASSERT(m_nItemHeight1>0);
    }

    ...

  • 相关阅读:
    微信app支付,服务端对接
    git 忽略文件权限
    linux 终端全局代理设置
    centos 谷歌浏览器安装
    putty快速设置本地代理
    centos rpmforge repo
    mysql 同步
    apscheduler 排程
    tornado 排程
    gedit 格式化json
  • 原文地址:https://www.cnblogs.com/tupx/p/3443024.html
Copyright © 2011-2022 走看看