In a typical MFC C++ dialog, I want to dynamically create a floating ListBox (or other standard control) over the dialog, possible extending past the dialog's boundaries - so it can't be a simple child or it'll be clipped.
Looking at something similar that works, I tried to achieve it but the window never appears when shown.
In my .h file I have:
CListBox m_ListBox;
Then in my OnInitDialog method (based on Serge's post):
BOOL CYourDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_ListBox.CreateEx(WS_EX_STATICEDGE | WS_EX_TOOLWINDOW, _T("LISTBOX"), NULL,
WS_CHILD | WS_CAPTION | LBS_STANDARD | WS_HSCROLL | WS_SYSMENU | WS_VISIBLE,
CRect(50, 100, 200, 200), this, 1);
m_ListBox.AddString(L"one");
m_ListBox.AddString(L"two");
m_ListBox.AddString(L"three");
return true;
}
The problem is the list-box is rendered beneath other controls in the dialog. I tried calling BringWindowToTop but it doesn't help.
Also, the new control can't extend beyond the edge of the dialog... since it's being used similar to the drop-list in a combo-box, that would be nice.