两个窗口怎么重叠

carter10004 2011-10-09 05:31:41
_declspec(dllexport) HWND g_BkWnd=NULL; ///-///背景窗口
_declspec(dllexport) HWND g_MainWnd=NULL;///-///主窗口

LRESULT CALLBACK CBTProc(int nCode,WPARAM wParam,LPARAM lParam)


case HCBT_MOVESIZE: ///-///一个窗口将被移动或改变尺寸:
{
HWND hWnd=(HWND)wParam;
if (g_MainWnd==hWnd)
{
CRect m_CRect_Main;
if(GetWindowRect(g_MainWnd,m_CRect_Main))
{
///-///
MoveWindow(g_BkWnd,m_CRect_Main.left,m_CRect_Main.top,(m_CRect_Main.right-m_CRect_Main.left),(m_CRect_Main.bottom-m_CRect_Main.top),true);
///-///MoveWindow(g_MainWnd,m_CRect_Main.left,m_CRect_Main.top,(m_CRect_Main.right-m_CRect_Main.left),(m_CRect_Main.bottom-m_CRect_Main.top),true);
///-///::SetWindowPos(g_BkWnd,HWND_BOTTOM,m_CRect_Main.left,m_CRect_Main.top,(m_CRect_Main.right-m_CRect_Main.left),(m_CRect_Main.bottom-m_CRect_Main.top),NULL);
::SetWindowPos(g_MainWnd,HWND_NOTOPMOST,m_CRect_Main.left,m_CRect_Main.top,(m_CRect_Main.right-m_CRect_Main.left),(m_CRect_Main.bottom-m_CRect_Main.top),SWP_NOMOVE|SWP_NOSIZE);
///-///::SetWindowPos(g_MainWnd,HWND_TOPMOST,m_CRect_Main.left,m_CRect_Main.top,(m_CRect_Main.right-m_CRect_Main.left),(m_CRect_Main.bottom-m_CRect_Main.top),NULL);
}
}
break;
}


我想把主窗口和背景窗口叠在一起,大小一致,主窗口在前,背景窗口在稍后。
所以,我给主窗口设了个CBTHOOK,代码如上:
可是怎么改,只要一移动主窗口,背景窗口就跑到主窗口前面。

哪里错误了?

这里的SetWindowPos好像效果不明显
...全文
325 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
carter10004 2011-10-10
  • 打赏
  • 举报
回复
好像是窗口的父子关系问题,我改了一下,已经改好了,只是还有一些问题。

1:移动主窗口时候,只要鼠标左键不弹起来,后面的“背景窗口”就不动,这个怎么办?

15,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧