0

I have designed activeX control which consist of one editbox and one combobox.

I am trying to place the editbox over combobox so that whenever the user select any item from the combobox it should sit to the editbox. So my editbox should coveringup combobox'edit portion and only the arrow button is visible for the combobox.

Isuue: Whenever I am trying to move my mouse cursor over that control the combobox is coming front of editbox.I have made the design such as editbox is just covering up the combobox but only when the focus goes back to combobox and that is taking the combobox front.

Tried Approaches: In one of the my defined function I tried all the below function to make edit box over the combobox.

1)BringWindowToTop

2)SetForegroundWindow

3)SetWindowPos

My code for that Function:

void DetermineWindowsShown()

{

 m_edit.EnableWindow(m_bEnabled);

m_combo.EnableWindow(m_bEnabled);

//here only I tried all the diff function
m_edit.BringWindowToTop();
//m_edit.SetForegroundWindow();
//m_combo.SetWindowPos(&CWnd::wndBottom ,0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);

}.

I am calling DetermineWindowsShown many places so that always editbox is above the combobox.

izhad
  • 19
  • 3
  • 1
    Why are you trying to re-invent a [Combo Box](https://msdn.microsoft.com/en-us/library/windows/desktop/bb775791.aspx) control in *simple* or *drop-down* style? What are you **really** trying to achieve? – IInspectable Jul 01 '15 at 09:58
  • Actually I want to do some operation on the item before I display to the user. We cannot set the edit box of combobox a different values from its item list so I am using the separate edit box. Eg combobx has items: abc,def,xyz. When I will select abc it should display abc123(123 a string I want to concatenate) and with a under line as well. – izhad Jul 02 '15 at 05:54
  • It would be easier if you make it owner draw control. – Barmak Shemirani Jul 03 '15 at 07:35

1 Answers1

0

BringWindowToTop is usually for MDI windows. SetForegroundWindow is for main window.

You should be able to use SetWindowPos, apply it to both, not just one:

m_combo.SetWindowPos(&CWnd::wndBottom, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
m_edit.SetWindowPos(&CWnd::wndTop, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
Barmak Shemirani
  • 30,904
  • 6
  • 40
  • 77