代码之家  ›  专栏  ›  技术社区  ›  user7022367

PowerBuilder应用程序如何充当另一个来宾可执行文件的主机?

  •  3
  • user7022367  · 技术社区  · 8 年前

    如何在PowerBuilder应用程序中作为子进程运行第三方可执行文件?

    我想要实现的唯一目标是,第三方exe文件的打开和关闭就像我们在PowerBuilder中打开和关闭工作表一样。

    我不想给我的应用程序的用户任何其他选项来关闭第三方exe,而不关闭我的主PowerBuilder应用程序。同样,不允许用户在不运行PowerBuilder应用程序的情况下运行第三方exe。

    所有这些听起来都像是ActiveX行为。所以我可以说,如果第三方exe变成ActiveX,那么我的目标就实现了。这只是我的猜测。真的,我可以选择任何其他符合要求的选项。

    2 回复  |  直到 8 年前
        1
  •  2
  •   Roland Smith    8 年前

    如果您有其他应用程序的窗口句柄,则可以使用SetParent API函数将其附加到PowerBuilder应用程序中的空白工作表窗口。图纸窗口的调整大小事件必须使用PB函数Send转发调整大小事件。然后,sheet窗口的close事件将发送WM\U close事件。

        2
  •  0
  •   Ankur Patel    8 年前

    有一种方法可以像在PowerBuilder应用程序中打开响应窗口一样打开第三方exe。虽然我不确定这是否对您有用,因为您希望像打开一个工作表窗口一样打开它。无论如何,下面是代码。

    本地外部功能定义:

    Function long FindWindowA (long classname,  string windowname) LIBRARY "user32.dll" alias for "FindWindowA;Ansi"
    Function Boolean BringWindowToTop (long classname) LIBRARY "user32.dll" alias for "BringWindowToTop;Ansi"
    

    本地功能:

    public function integer of_manage_third_party_exe ()
    public function integer of_manage_third_party_exe ();///////////////////////////////////////////////////////////////////////////////////
    //
    // Returns 1 - window is not opened
    //              -1 : A window is opened so bring it to top
    //
    ///////////////////////////////////////////////////////////////////////////////////
    long    ll_handle           //unique id of window opened
    
    ll_handle = FindWindowA(0,"Title of third party exe")       
    
    //If the window is not opened Then bring the window to top
    If ll_handle > 0 Then
        Post BringWindowToTop(ll_handle)
        Return -1
    End If
    
    Return 1
    

    框架窗口/要从中打开第三方exe的窗口的激活事件中的脚本:

    of_manage_third_party_exe()
    

    CloseQuery事件中的脚本:

    //if third party exe is open then don't allow to close the window
    If of_manage_third_party_exe ( ) < 0 Then
        Return 1
    End If
    

    我想这将帮助您根据您的功能找出可能需要使用of\u manage\u third\u party\u exe功能的其他地方。