如何以编程方式将CCombox添加到MFC应用程序 [英] How to add a CCombox programatically to an MFC Application

查看:178
本文介绍了如何以编程方式将CCombox添加到MFC应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在表单上以编程方式添加ccombobox控件。我正在使用以下代码:

I need to add a ccombobox control programatically on the form. I'm using the following code:

CComboBox * m_searchComboBox = new CComboBox();

    if (! m_searchComboBox->Create( WS_VISIBLE | WS_CHILD | WS_BORDER | WS_VSCROLL | CBS_DROPDOWN,  CRect(200,25,300,15), this, IDC_COMBO_OD_COUNTRIES ))
        		TRACE0("Failed to create search bar\n");



它绘制组合框但不是所有其他组合的顶部控件,我无法使用它,因为下面的面板覆盖了组合框。此外,我希望它位于标题栏的左侧,但是当我增加CRect构造函数的第一个参数的值以增加左边距时,组合框从表单中消失,就像它被左面板完全覆盖一样。简单来说,我希望将最顶层的标志传递给Create方法来解决这个问题。任何帮助将不胜感激。


It draws the combobox but not on the top of all other controls, I can not use it because the panel below covers the combobox. Moreover I want it to be on the left side of title bar but when I increase the value of the first parameter of CRect constructor to increase the left margin, the combobox disappears from the form like if it is completely covered by the left panel. In simple words I want the top-most flag to be passed to the Create method to solve this issue. Any help would be appreciated.

推荐答案

您需要更改Tab键顺序,看看: SetWindowPos [ ^ ]



执行以下操作:



You need to change the tab order, take a look: SetWindowPos[^]

Do something like:

GetDlgItem(IDC_COMBO_OD_COUNTRIES)->SetWindowPos(HWND_TOPMOST,
                                        200,25,300,15,
                                        SWP_NOMOVE | SWP_NOSIZE);


这篇关于如何以编程方式将CCombox添加到MFC应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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