如何防止CView派生类获得输入焦点 [英] How to prevent a CView derived class from gaining the input focus

查看:158
本文介绍了如何防止CView派生类获得输入焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道在事件发生之前如何处理CView派生类上的输入焦点事件.这就像调用OnSettingFocus,如果存在这样的事件处理程序,然后取消输入焦点,以使我的视图从不获得输入焦点(出于某些原因).
注意:CWnd::EnableWindow(FALSE);无法正常工作,因为我的视图有一个子视图,调用CWnd::EnableWindow(FALSE);也会使该子视图被禁用.
请帮助我做到这一点:(

I''m wondering how to handle an input focus event on a CView derived class before the event occurs. It''s like calling a OnSettingFocus if such an event handler exists, and then cancel the input focus, to make my view never gaining the input focus (for some reasons).
NB: CWnd::EnableWindow(FALSE); wont work, because my view has a child view and the call of CWnd::EnableWindow(FALSE); will make the child view disabled also.
Help me please to do that :(

推荐答案

EnableWindow(0);


这很简单. ;-)


Thats easy. ;-)


BEGIN_MESSAGE_MAP(CSomeRecordSetView, CFormView)
    ON_COMMAND(ID_RECORD_NEXT_MM, OnRecordNextMm)
 END_MESSAGE_MAP()





void CSomeRecordSetView::OnRecordNextMm()
{
    if (m_CurrentRecord < m_NumRecords - 1)
    {
        // open set
        m_pSet->Open();

        // move to the incremented record
        m_pSet->Move(++m_CurrentRecord);

        // copy data from set to view
        DataExchange(m_pSet, TRUE);

        // cause re-draw
        UpdateData(FALSE);

        // close the set
        m_pSet->Close();

    }
}




DataExchange方法(您必须编写此方法)将数据从RecordSet移到View(参数为TRUE时),反之亦然(参数为FALSE时),例如,




DataExchange method (you have to write this) moves data from RecordSet to View (whan argument is TRUE) and vice versa (when argument is FALSE), e.g.

void CSomeRecordSetView::DataExchange(CSomeRecordSet *pSet, BOOL Direction)
{
    if (Direction)
    {
        // copy from recordSet to view
        m_SomeData = m_pSet->m_SomeData;
    }
    else
    {
        // copy from dialog to recordset
        m_pSet->m_SomeData = m_SomeData;
    }
}




据我所知,它取代了RecordSet视图下一步"按钮的默认行为.上一个,第一个和最后一个相似.




This, as far as I remember, replaces the default behaviour of RecordSet view Next button. Prev, First and Last are similar.


这篇关于如何防止CView派生类获得输入焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆