如何让窗体显示在最前端

chenyang80425 2008-12-18 02:07:21
请问MFC如何在前端显示一个窗体,而不把焦点给它.就像QQ消息那种.窗口可以一直显示在最右下角最前端.而可以不获得焦点.不影响做其它事.
...全文
294 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
zw0558 2008-12-19
  • 打赏
  • 举报
回复
两种途径.

BringWindowToTop(Handle);

SetWindowPos函数,指定窗口的 最顶风格,用WS_EX_TOPMOST扩展窗口的 风格

Example:



C/C++ code
void ToggleTopMost( CWnd *pWnd)

{

ASSERT_VALID(pWnd);

pWnd ->SetWindowPos(pWnd-> GetStyle( ) &WS_EX_TOPMOST)?

&wndNoTopMOST: &wndTopMost,0,0,0,0,SSP_NOSIZE|WSP_NOMOVE);

}

zw0558 2008-12-19
  • 打赏
  • 举报
回复
up
路人乙2019 2008-12-19
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 janjone 的回复:]
CRect rect;
CRect Dlgrect;
GetWindowRect(&Dlgrect);
::GetWindowRect(GetDesktopWindow()->GetSafeHwnd(), rect);
::SetWindowPos(m_hWnd, HWND_TOPMOST, rect.right - Dlgrect.right-50, rect.top, Dlgrect.Width(), Dlgrect.Height(), SWP_SHOWWINDOW);
[/Quote].
janjone 2008-12-19
  • 打赏
  • 举报
回复
CRect rect;
CRect Dlgrect;
GetWindowRect(&Dlgrect);
::GetWindowRect(GetDesktopWindow()->GetSafeHwnd(), rect);
::SetWindowPos(m_hWnd, HWND_TOPMOST, rect.right - Dlgrect.right-50, rect.top, Dlgrect.Width(), Dlgrect.Height(), SWP_SHOWWINDOW);
complier199 2008-12-19
  • 打赏
  • 举报
回复
ding
ooily 2008-12-19
  • 打赏
  • 举报
回复
ding
ilovedrv 2008-12-19
  • 打赏
  • 举报
回复
两种途径.

BringWindowToTop(Handle);

SetWindowPos函数,指定窗口的 最顶风格,用WS_EX_TOPMOST扩展窗口的 风格

Example:



void ToggleTopMost( CWnd *pWnd)

{

ASSERT_VALID(pWnd);

pWnd ->SetWindowPos(pWnd-> GetStyle( ) &WS_EX_TOPMOST)?

&wndNoTopMOST: &wndTopMost,0,0,0,0,SSP_NOSIZE|WSP_NOMOVE);

}




Eleven 2008-12-19
  • 打赏
  • 举报
回复
SetWindowPos(&wndTopMost,...)
Learn-anything 2008-12-19
  • 打赏
  • 举报
回复
楼上说的比较全
up
长尾巴的悟空 2008-12-19
  • 打赏
  • 举报
回复
设置成顶层窗口模式.
bitwwzhang130 2008-12-18
  • 打赏
  • 举报
回复
设置为TOPMOST样式
harry330 2008-12-18
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 ankyers 的回复:]
你在的对话框文件的::OnInitDialog()下加入:
CRect rect;
GetWindowRect(&rect);
SetWindowPos(&wndTopMost,rect.left,rect.top,rect.Width(),rect.Height(),SWP_NOMOVE);
[/Quote]
这个OK
windyloft 2008-12-18
  • 打赏
  • 举报
回复
SetWindowPos
ankyers 2008-12-18
  • 打赏
  • 举报
回复
你在的对话框文件的::OnInitDialog()下加入:
CRect rect;
GetWindowRect(&rect);
SetWindowPos(&wndTopMost,rect.left,rect.top,rect.Width(),rect.Height(),SWP_NOMOVE);
lotusword 2008-12-18
  • 打赏
  • 举报
回复
另外创建的时候设置
::SetWindowPos(this->m_hWnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE);
lotusword 2008-12-18
  • 打赏
  • 举报
回复
创建非模态窗口

15,979

社区成员

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

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