只能截获最小化消息: type procedure MyMessage(var msg:Tmsg);message wm_syscommand;... procedure TForm1.Timer1Timer(Sender: TObject); begin FlashWindow(Application.Handle,true); end;procedure TForm1.MyMessage(var msg: Tmsg); begin inherited; if msg.message=61472 then Timer1.Enabled:=true else Timer1.Enabled:=false; end;procedure TForm1.FormPaint(Sender: TObject); begin if self.WindowState=wsMinimized then Timer1.Enabled:=true else Timer1.Enabled:=false; end;
好像用 BOOL SetForegroundWindow( HWND hWnd // handle of window to bring to foreground );更好一些不用判断是否是最小化的,msn在接收到message时,调用setforegroundwindow(此时,如果你的应用在screen的最上面就什么都不做,否则就会努力把自己的form调到上面来,这时窗口就是闪烁的)
截WM_SYSCOMMAND消息 procedure TGZMForm.WMSysCommand(var Msg: TWMSysCommand); begin if Msg.CmdType = SC_MINIMIZE then Application.Minimize else inherited; end;
判断最大最小化可以在onresize事件里判断windowstate,1为最小,2 为最大,0为normal
type procedure MyMessage(var msg:Tmsg);message wm_syscommand;...
procedure TForm1.Timer1Timer(Sender: TObject);
begin
FlashWindow(Application.Handle,true);
end;procedure TForm1.MyMessage(var msg: Tmsg);
begin
inherited;
if msg.message=61472 then Timer1.Enabled:=true else Timer1.Enabled:=false;
end;procedure TForm1.FormPaint(Sender: TObject);
begin
if self.WindowState=wsMinimized then Timer1.Enabled:=true else Timer1.Enabled:=false;
end;
BOOL SetForegroundWindow( HWND hWnd // handle of window to bring to foreground
);更好一些不用判断是否是最小化的,msn在接收到message时,调用setforegroundwindow(此时,如果你的应用在screen的最上面就什么都不做,否则就会努力把自己的form调到上面来,这时窗口就是闪烁的)
procedure TGZMForm.WMSysCommand(var Msg: TWMSysCommand);
begin
if Msg.CmdType = SC_MINIMIZE then
Application.Minimize
else
inherited;
end;