C++Builder 程序员博客
5 Sep
一个程序A在运行,在定时器中设置定时,每隔5分钟提示一个信息,如何让这个提示信息窗口显示在最前面?
用了一下方法都不行,有什么办法?
BringWindowToTop(Application->Handle);
或
SetWindowPos(Application->Handle,Application->Handle,1,1,800,600,0);
或
LPDWORD lpdwProcessId;
DWORD ll = GetWindowThreadProcessId(GetForegroundWindow,NULL);
AttachThreadInput(ll,GetCurrentThreadId(),True);
SetForegroundWindow(tmp->Handle);
SetFocus();
ll = GetWindowThreadProcessId(GetForegroundWindow(),NULL);
AttachThreadInput(ll,GetCurrentThreadId(),False);
SetWindowPos(Application->Handle,HWND_TOP,1,1,800,600,SWP_SHOWWINDOW);
不行呀,执行之后只会在底下的任务栏中中闪烁,无法弹出窗口
WIN API 函数 SetForegroundWindow 把窗口拿到最前面
BOOL SetForegroundWindow
(
HWND hWnd // handle of window to bring to foreground
);
我的环境是xp,用SetForegroundWindow也不行呀
那直接用BringToFront();
ShowWindow可以试一下
ShowMessage("提示在最前面");
Form1->FormStyle=fsStayOnTop;
把你要弹出的窗体ShowModel不行嘛
SetParent试试
很简单嘛
如下:
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
Form2->Show();
Form2->BringToFront();
}
如果想显示后再隐藏,可以在Form2->BringToFront(); 后再隐藏。
该回复于2008-07-19 16:09:45被版主删除