怎样使最近打开的窗口成为唯一能接受焦点的窗体?
如果使用FormStyle:=fsStayOnTop不是好的办法。
因为如果窗体Form1的FormStyle:=fsStayOnTop,当
从Form1中打开的Form2的FormStyle:=fsStayOnTop
则不能达到目的了。

解决方案 »

  1.   

    如果窗体不是很多,你在最近打开的窗口的oncreate事件中可以把其他窗体设为不能用.当关闭改窗体时,在onclose事件中再把其他窗体的焦点释放
      

  2.   

    所有窗体都以模式方式打开不就行了(ShowModal)
      

  3.   

    用SetActiveWindowSetActiveWindow
    The SetActiveWindow function activates a window. The window must be attached to the calling thread's message queue. HWND SetActiveWindow(
      HWND hWnd   // handle to window
    );
    Parameters
    hWnd 
    [in] Handle to the top-level window to be activated. 
    Return Values
    If the function succeeds, the return value is the handle to the window that was previously active. If the function fails, the return value is NULL. To get extended error information, call GetLastError.Res
    The SetActiveWindow function activates a window, but not if the application is in the background. The window will be brought into the foreground (top of Z order) if its application is in the foreground when the system activates the window. If the window identified by the hWnd parameter was created by the calling thread, the active window status of the calling thread is set to hWnd. Otherwise, the active window status of the calling thread is set to NULL.By using the AttachThreadInput function, a thread can attach its input processing to another thread. This allows a thread to call SetActiveWindow to activate a window attached to another thread's message queue. Requirements 
      Windows NT/2000/XP: Included in Windows NT 3.1 and later.
      Windows 95/98/Me: Included in Windows 95 and later.
      Header: Declared in Winuser.h; include Windows.h.
      Library: Use User32.lib.
    --------------------------------------
    看见了么,
    那支蛾子,
    正飞向太阳,
    那就是我!
    --------------------------------------
      

  4.   

    唯一能接受焦点的窗体?ft,showmodal就行了阿
    --------------------------------------
    看见了么,
    那支蛾子,
    正飞向太阳,
    那就是我!
    --------------------------------------
      

  5.   

    将窗体改为全屏显示,再调用窗体的showmodal方法。