比如WORD里的字体大小设置组合框,选择某个字号后
光标还是在框架的客户区的谢谢

解决方案 »

  1.   

    使用CNewComboBox 类替换掉工具条上的下拉框变量的声明
    CNewComboBox派生自CComboBox类,在OnSelchange消息响应函数内部,可调用其它窗体的SetFocus()函数失去焦点,如下示例:#if !defined(AFX_NEWCOMBOBOX_H__BD490F63_79C1_49A0_9DC5_7161DDCFAB4B__INCLUDED_)
    #define AFX_NEWCOMBOBOX_H__BD490F63_79C1_49A0_9DC5_7161DDCFAB4B__INCLUDED_#if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000
    // NewComboBox.h : header file
    ///////////////////////////////////////////////////////////////////////////////
    // CNewComboBox windowclass CNewComboBox : public CComboBox
    {
    // Construction
    public:
    CNewComboBox();// Attributes
    public:// Operations
    public:// Overrides
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CNewComboBox)
    //}}AFX_VIRTUAL// Implementation
    public:
    virtual ~CNewComboBox(); // Generated message map functions
    protected:
    //{{AFX_MSG(CNewComboBox)
    afx_msg void OnSelchange();
    //}}AFX_MSG DECLARE_MESSAGE_MAP()
    };///////////////////////////////////////////////////////////////////////////////{{AFX_INSERT_LOCATION}}#endif #include "stdafx.h"
    #include "NewComboBox.h"#ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endif/////////////////////////////////////////////////////////////////////////////
    // CNewComboBoxCNewComboBox::CNewComboBox()
    {
    }CNewComboBox::~CNewComboBox()
    {
    }
    BEGIN_MESSAGE_MAP(CNewComboBox, CComboBox)
    //{{AFX_MSG_MAP(CNewComboBox)
    ON_CONTROL_REFLECT(CBN_SELCHANGE, OnSelchange)
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()
    void CNewComboBox::OnSelchange() 
    {
    AfxGetMainWnd()->SetFocus();
    }