如题,我在B的主窗体的Close事件中写如下代码不行啊。var
  HWndApp: HWnd;
begin
  HWndApp := Winprocs.FindWindow(nil, Pchar(A的窗口标题名));
  if HWndApp <> 0 then
    PostMessage(HWndApp, WM_SHOWWINDOW, 0, 0);

解决方案 »

  1.   

    PostMessage(HWndApp, WM_SHOWWINDOW, 0, 0) 也不行
      

  2.   

    SendMessage(HWndApp, WM_SHOWWINDOW, 0, 0);
      

  3.   

    SendMessage(HWndApp, WM_SHOWWINDOW, 0, 0)也不行
      

  4.   

    ShowWindow确实可以,但是带来另一个问题是A不能再最小化了,奇怪。
      

  5.   

    我也不知道为什么!
    ShowWindow()的可选参数
    SW_FORCEMINIMIZE Windows NT 5.0 and later: Minimizes a window, even if the thread that owns the window is hung. This flag should only be used when minimizing windows from a different thread. SW_HIDE Hides the window and activates another window. SW_MAXIMIZE Maximizes the specified window. SW_MINIMIZE Minimizes the specified window and activates the next top-level window in the Z order. SW_RESTORE Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when restoring a minimized window.
     
    SW_SHOW Activates the window and displays it in its current size and position. 
     
    SW_SHOWDEFAULT Sets the show state based on the SW_ flag specified in theSTARTUPINFO structure passed to theCreateProcess function by the program that started the application. 
     
    SW_SHOWMAXIMIZED Activates the window and displays it as a maximized window. SW_SHOWMINIMIZED Activates the window and displays it as a minimized window. SW_SHOWMINNOACTIVE Displays the window as a minimized window. The active window remains active. SW_SHOWNA Displays the window in its current state. The active window remains active. SW_SHOWNOACTIVATE Displays a window in its most recent size and position. The active window remains active. SW_SHOWNORMAL Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time. 
      

  6.   

    解决了。在B程序中用SendMessage向A发送一个消息,A中
      

  7.   

    解决了。在B程序中用SendMessage(h, WM_COPYDATA, 0, 字符串)向A发送一个消息,A中定义过程   
     procedure GetCopyData(var Msg: TWmCopyData); message WM_COPYDATA;
    来执行收到消息后的事件(恢复窗口大小)就可以了