创建两个CWnd对象pwnd 和pwnd2,将其Create()出来,分别标注为A和B。根据下面的代码,A和B将部分重叠,且B在A之上。但当点击重叠部分时,响应点击的却是A而非B。即使添加代码C1和C2,重设置Z-order或用CWnd::SetForegroundWindow(),
CWnd::SetFocus()也不行。
BOOL CXXXDlg::OnInitDialog()
{
...... CRect rect(50,50,100,100);
pwnd=new CWnd;
pwnd->Create("Button",NULL,WS_VISIBLE|WS_CHILD,rect,this,0);
pwnd->SetWindowText(" A ");
// pwnd->SetWindowPos(&wndBottom ,50,50,50,50, SWP_DRAWFRAME ) ; // C1 CRect rect2(75,50,125,100);
pwnd2=new CWnd;
pwnd2->Create("Button",NULL,WS_VISIBLE|WS_CHILD,rect2,this,0);
pwnd2->SetWindowText(" B ");
// pwnd2->SetWindowPos(&wndTopMost , 75,50,50,50, SWP_DRAWFRAME); // C2
}怎样才能实现点击重叠部分时,B响应点击???
CWnd::SetFocus()也不行。
BOOL CXXXDlg::OnInitDialog()
{
...... CRect rect(50,50,100,100);
pwnd=new CWnd;
pwnd->Create("Button",NULL,WS_VISIBLE|WS_CHILD,rect,this,0);
pwnd->SetWindowText(" A ");
// pwnd->SetWindowPos(&wndBottom ,50,50,50,50, SWP_DRAWFRAME ) ; // C1 CRect rect2(75,50,125,100);
pwnd2=new CWnd;
pwnd2->Create("Button",NULL,WS_VISIBLE|WS_CHILD,rect2,this,0);
pwnd2->SetWindowText(" B ");
// pwnd2->SetWindowPos(&wndTopMost , 75,50,50,50, SWP_DRAWFRAME); // C2
}怎样才能实现点击重叠部分时,B响应点击???
解决方案 »
- 如何二进制补码求校验和。 Checksum为2's complement sum of message contents excluding checksum。
- Dialog程序怎样操作Windows的cmd(命令提示符)?
- VC如何读取COOKIES呢?显示基内容.网上找了下,没找到答案..
- ATL控件 在Performing registration时停止不动
- 怎样确定窗口的大小?以及出现位置?
- VARIANT或COleVariant如何转成CString?
- Navigate到一页面,然后Put上我的数据,出现的问题?? masterz,jiangsheng 希望也来
- 郁闷残了,VC6.0的补丁安装不成功!
- ★★★★★讨论:数据库更新后自动通知我的程序,如何实现----来者有分★★★★★
- 如何转换坐标?
- 深入浅出MFC问题--求助???
- 人家过年,我来散分
pwnd2->Create("Button",NULL,WS_VISIBLE|WS_CHILD,rect2,this,0);
两个窗口的ID号好像不可以相同啊
http://expert.csdn.net/Expert/topic/1404/1404676.xml?temp=.4430963
>>pwnd2->SetFocus(); // that's a mistake.To: eEric(Paranoia)
你可能犯了一個和hnyyy(前进) 一樣的小錯誤。
according to msdn: CWnd::SetFocus
"Call this member function to claim the input focus. The input focus directs all subsequent keyboard input to this window. Any window that previously had the input focus loses it.""If the current window is active but does not have the focus (that is, no window has the focus), any key pressed will produce the messages WM_SYSCHAR, WM_SYSKEYDOWN, or WM_SYSKEYUP. "So, try pwnd->SetFocus(); // not pwnd2 in the case.
sorry to: hnyyy(前进).
void CYourDlg::OnButton1()
{
GetDlgItem(IDC_BUTTON1)->BringWindowToTop();
}void CYourDlg::OnButton2()
{
GetDlgItem(IDC_BUTTON2)->BringWindowToTop();}这样就可以保证以后显示最前的能获得消息。然而最初显示时TABORDER在前的,却显示在下面。以致第一次有点问题,你自己解决吧。
如果只想b在a上﹐ 可以用WS_POPUP。
pwnd2->CreateEx(NULL, "Button", NULL, WS_VISIBLE|WS_CHILD|WS_POPUP, rect2, this, 0);
的派生类产生对象,存在同样的问题。
我只想让在上边的子窗体响应点击.
pwnd=new CWnd;
pwnd->Create("Button",NULL,WS_VISIBLE|WS_CHILD,rect,this,1425);
pwnd->SetWindowText(" A ");
// pwnd->SetWindowPos(&wndBottom ,50,50,50,50, SWP_DRAWFRAME ) ; // C1 CRect rect2(75,50,125,100);
pwnd2=new CWnd;
pwnd2->Create("Button",NULL,WS_VISIBLE|WS_CHILD,rect2,this,1426);
pwnd2->SetWindowText(" B ");
pwnd->SetWindowPos(pwnd2 , 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE);
the difference is not only SWP_NOMOVE, but the HWND hWndInsertAfter parameter.