点击对话框中的按钮创建一个listbox子窗口,listbox位于按钮的中间,即我想让listbox遮住button一半,然后即使鼠标放在button上,listbox也应该在button之上,而不是被button给遮住。这个要怎么做?代码如下: //得到按钮的位置信息
CRect rcBtn;
m_Ctl_Btn_CreateListBox.GetWindowRect(rcBtn);
ScreenToClient(rcBtn); //创建listbox
m_wndListBox.reset(new CListBox());
CRect rcListBox( CPoint(rcBtn.left + rcBtn.Width()/2, rcBtn.top), CSize(40,100) );
m_wndListBox->Create(WS_CHILD|WS_VISIBLE, rcListBox, this, 0x5644); //添加listitem
m_wndListBox->AddString(L"A");
m_wndListBox->AddString(L"B");
m_wndListBox->AddString(L"C");
m_wndListBox->AddString(L"D");
m_wndListBox->AddString(L"E"); //显示
m_wndListBox->ShowWindow(SW_SHOW); //调制listbox的位置,但无法生效?
m_wndListBox->SetWindowPos(
&m_Ctl_Btn_CreateListBox,
rcListBox.left,
rcListBox.top,
rcListBox.Width(),
rcListBox.Height(),
SWP_SHOWWINDOW
);
CRect rcBtn;
m_Ctl_Btn_CreateListBox.GetWindowRect(rcBtn);
ScreenToClient(rcBtn); //创建listbox
m_wndListBox.reset(new CListBox());
CRect rcListBox( CPoint(rcBtn.left + rcBtn.Width()/2, rcBtn.top), CSize(40,100) );
m_wndListBox->Create(WS_CHILD|WS_VISIBLE, rcListBox, this, 0x5644); //添加listitem
m_wndListBox->AddString(L"A");
m_wndListBox->AddString(L"B");
m_wndListBox->AddString(L"C");
m_wndListBox->AddString(L"D");
m_wndListBox->AddString(L"E"); //显示
m_wndListBox->ShowWindow(SW_SHOW); //调制listbox的位置,但无法生效?
m_wndListBox->SetWindowPos(
&m_Ctl_Btn_CreateListBox,
rcListBox.left,
rcListBox.top,
rcListBox.Width(),
rcListBox.Height(),
SWP_SHOWWINDOW
);
m_wndListBox->SetWindowPos(
&CWnd::wndTopMost,
rcListBox.left,
rcListBox.top,
rcListBox.Width(),
rcListBox.Height(),
SWP_SHOWWINDOW
);
这样也不可以!
WS_CHILD风格的listbox才可以!都是WS_CHILD的窗口应该无法做到一致在某一个控件窗口的前面吧,即没有办法置顶吧!
第一个参数改为HWND_TOP 和 HWND_TOPMOST 都无效么?
嗯,都是WS_CHILD的话,这两个参数都无效!
http://bbs.csdn.net/topics/390274670