一个提醒器,其中时间到了设定的时间就提示,我的代码如下:
  showmessage('时间到');
但是如果在此期间有正在运行着的其他程序的话,这个提示信息就看不到,怎样做才能让它出现在最前面呢?

解决方案 »

  1.   

    用如下代碼:
     Application.BringToFront;
     Application.ProcessMessage;
     ShowMessage(.....
      

  2.   

    to aiirii(ari) 
       你的方法不行!刚试了
    难道非得再做一个窗体吗?
      

  3.   

    function SetSysFocus(hwnd: integer): integer;
    var
      hOtherWin,OtherTHreadID,hFocusWin:integer;
    begin
      hOtherWin:=GetForegroundWindow;
      OtherThreadID:=GetWindowThreadProcessID(hOtherWin,nil);
      if AttachThreadInput(GetcurrentThreadID,OtherThreadID,True) then
      begin
        hFocusWin:=GetFocus;
        windows.SetFocus(hwnd);
        //SendMessage(hwnd,WM_COPY,0,0);
        if hFocusWin<>0 then
        try
          //SendMessage(GetFocus,WM_COPY,0,0);
        finally
          AttachThreadInput(GetCurrentTHreadID,OtherTHreadID,False);
        end;
      end
      else result:=Windows.SetFocus(hwnd);
    end;
    这样用SetSysFocus(Application.Handle);
    就会在最前面了
    这里是以前的代码
    功能是使窗体得到焦点.这与此同时,如果你能将窗体设为最上,那你的窗体因为得到焦点,就一定在最上了.
    你可以这样写!
    SetSysFocus(Application.Handle);
    showmessage('...');
      

  4.   

    ShowModal, FormStyle:=fsStayOnTop 试试。
      

  5.   

    SetWindowPos(Form1.Handle,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE Or SWP_NOSIZE);
     SetWindowPos(Form1.Handle,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE Or SWP_NOSIZE);
    第一句把Form1置为总在最前的窗口,第2句取消,这样窗口就跑到前面来了.
      

  6.   

    MessageBox(0, '', 'ok', '', 0);
      

  7.   

    还是miky(miky) 厉害!调试通过!谢谢!!!
    还想讨论一下如何能实现金山毒霸的整点报时类似的功能(提示比较美观,目前的方案比较死板)
    明晚结帖!!!
      

  8.   

    你是说messagebox调用时用到的handel吧,传入0就可以了,表示在桌面上