我在程序出一开始就打开主窗口,另外再ShowModal一个登录窗口,假如这时有用WEB控件弹出一个广告页面,这个广告是背投的,这时这个主窗口会自动(不是人为)失去焦点,而这个登录窗口被隐藏在后面,然后鼠标点回来会什么都点不了,(因为看不到登录窗口),而用TAB+SHIT置到这个程序时,才会出现登录窗口。
不知道怎么解决这种,有时候会出现这种showmodal的窗口跑到背后去,然后主窗口又点不了的状况

解决方案 »

  1.   

    WEB控件弹出一个广告页面,这已经不是你那个程序内部的东东了,一个ShowModal是不行的
      

  2.   

    搞一个ontop样式的form试试,能否被挡住
      

  3.   

    谢谢你的回复,那个登录窗口本来就是stayontop的。
    另外,如果只是弹出去,点底下任务栏的程序回来能到主窗口+登录窗口显示的也行的。关键是点回来,登录窗口不会显示
      

  4.   

    窗体showmodal再加上ontop试试看吧。
      

  5.   

    试试: FormStyle := fsStayOnTop
      

  6.   

    我的登录窗体是fsStayOnTop,不过主窗体不是就是有时候像上述的情况登录窗体会跑到背后。。然后所有都点不到。
      

  7.   

    参考:
    function TApplication.MessageBox(const Text, Caption: PChar; Flags: Longint): Integer;
    var
      ActiveWindow: HWnd;
      WindowList: Pointer;
      MBMonitor, AppMonitor: HMonitor;
      MonInfo: TMonitorInfo;
      Rect: TRect;
      FocusState: TFocusState;
    begin
      ActiveWindow := GetActiveWindow;
      MBMonitor := MonitorFromWindow(ActiveWindow, MONITOR_DEFAULTTONEAREST);
      AppMonitor := MonitorFromWindow(Handle, MONITOR_DEFAULTTONEAREST);
      if MBMonitor <> AppMonitor then
      begin
        MonInfo.cbSize := Sizeof(TMonitorInfo);
        GetMonitorInfo(MBMonitor, @MonInfo);
        GetWindowRect(Handle, Rect);
        SetWindowPos(Handle, 0,
          MonInfo.rcMonitor.Left + ((MonInfo.rcMonitor.Right - MonInfo.rcMonitor.Left) div 2),
          MonInfo.rcMonitor.Top + ((MonInfo.rcMonitor.Bottom - MonInfo.rcMonitor.Top) div 2),
          0, 0, SWP_NOACTIVATE or SWP_NOREDRAW or SWP_NOSIZE or SWP_NOZORDER);
      end;
      WindowList := DisableTaskWindows(0);
      FocusState := SaveFocusState;
      if UseRightToLeftReading then Flags := Flags or MB_RTLREADING;
      try
        Result := Windows.MessageBox(Handle, Text, Caption, Flags);
      finally
        if MBMonitor <> AppMonitor then
          SetWindowPos(Handle, 0,
            Rect.Left + ((Rect.Right - Rect.Left) div 2),
            Rect.Top + ((Rect.Bottom - Rect.Top) div 2),
            0, 0, SWP_NOACTIVATE or SWP_NOREDRAW or SWP_NOSIZE or SWP_NOZORDER);
        EnableTaskWindows(WindowList);
        SetActiveWindow(ActiveWindow);
        RestoreFocusState(FocusState);
      end;
    end;
      

  8.   

    Alt+Tab 切到你的程序 登录窗口就在上面了  呵呵怎么避免这个情况的出现该怎么处理 不知道了