Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
1.27/5 (3 votes)
See more:
I need to add a ccombobox control programatically on the form. I'm using the following code:
C++
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");

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.
Posted
Updated 3-Jul-15 4:18am
v3

1 solution

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

Do something like:

C++
GetDlgItem(IDC_COMBO_OD_COUNTRIES)->SetWindowPos(HWND_TOPMOST,
                                        200,25,300,15,
                                        SWP_NOMOVE | SWP_NOSIZE);
 
Share this answer
 
v3
Comments
Leo Chapiro 6-Jul-15 4:19am    
Why is my answer downvoted?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900