zoukankan      html  css  js  c++  java
  • duilib的caption上的Edit无法激活

    当窗口设置标题栏时,鼠标等控件可以相应,edit无法响应。

    主要和WindowImplBase::OnNcHitTest 虚函数有关。

    LRESULT WindowImplBase::OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    {
    POINT pt; pt.x = GET_X_LPARAM(lParam); pt.y = GET_Y_LPARAM(lParam);
    ::ScreenToClient(*this, &pt);

    RECT rcClient;
    ::GetClientRect(*this, &rcClient);

    if( !::IsZoomed(*this) )
    {
    RECT rcSizeBox = m_PaintManager.GetSizeBox();
    if( pt.y < rcClient.top + rcSizeBox.top )
    {
    if( pt.x < rcClient.left + rcSizeBox.left ) return HTTOPLEFT;
    if( pt.x > rcClient.right - rcSizeBox.right ) return HTTOPRIGHT;
    return HTTOP;
    }
    else if( pt.y > rcClient.bottom - rcSizeBox.bottom )
    {
    if( pt.x < rcClient.left + rcSizeBox.left ) return HTBOTTOMLEFT;
    if( pt.x > rcClient.right - rcSizeBox.right ) return HTBOTTOMRIGHT;
    return HTBOTTOM;
    }

    if( pt.x < rcClient.left + rcSizeBox.left ) return HTLEFT;
    if( pt.x > rcClient.right - rcSizeBox.right ) return HTRIGHT;
    }

    RECT rcCaption = m_PaintManager.GetCaptionRect();
    if( pt.x >= rcClient.left + rcCaption.left && pt.x < rcClient.right - rcCaption.right
    && pt.y >= rcCaption.top && pt.y < rcCaption.bottom ) {
    CControlUI* pControl = static_cast<CControlUI*>(m_PaintManager.FindControl(pt));
    if( pControl && _tcsicmp(pControl->GetClass(), _T("ButtonUI")) != 0 &&
    _tcsicmp(pControl->GetClass(), _T("OptionUI")) != 0 &&
    _tcsicmp(pControl->GetClass(), _T("TextUI")) != 0 &&
    _tcsicmp(pControl->GetClass(), _T("SliderUI")) != 0)
    return HTCAPTION;
    }

    return HTCLIENT;
    }

    在返回caption区域时,只排除了ButtonUI、OptionUI、TextUI、SliderUI四种控件。

    所以解决办法是:在派生自WindowImplBase的对话框中重写OnNcHitTest,将EditUI加进去即可。

  • 相关阅读:
    Codeforces 1528E Mashtali and Hagh Trees
    Codeforces Round #709 (Div. 1, based on Technocup 2021 Final Round)
    Codeforces 1517G Starry Night Camping
    Codeforces 1508E Tree Calendar
    Codeforces 1508D Swap Pass
    Codeforces 1511G Chips on a Board
    Codeforces 1511F Chainword
    Codeforces 1516E Baby Ehab Plays with Permutations
    CF1539A Contest Start 题解
    关于 manacher
  • 原文地址:https://www.cnblogs.com/criticalsection/p/6148241.html
Copyright © 2011-2022 走看看