【问题标题】:Host qt application in WPF在 WPF 中托管 qt 应用程序
【发布时间】:2018-05-02 18:20:09
【问题描述】:

我正在尝试在 windowsforms/wpf 应用程序中托管 QT 应用程序的窗口。我已经看到了很多关于这个问题的问题和答案。但它们对我不起作用(窗口不会以 wpf 形式显示,并且会自行运行)。 我有一个必须在 Windows 上以管理员模式启动的应用程序。当我尝试使用 SetParent 在我的应用程序中嵌入/托管它时,它不会显示,并且 SetParent 返回 0。

notepad++ 等其他应用程序也可以工作,我是否需要执行其他步骤来托管管理员模式窗口?

编辑 1:

        int h = FindWindow(null, "Game Browser");
        IntPtr hwnd = (IntPtr)h;
        // Both h and hwnd are set to correct values

        var helper = new WindowInteropHelper(this);
        var x = SetParent(hwnd, helper.Handle);
        // x remains 0, helper.Handle returns a seemingly correct value

        // remove control box
        int style = GetWindowLong(hwnd, GWL_STYLE);
        style = style & ~WS_CAPTION & ~WS_THICKFRAME;
        SetWindowLong(hwnd, GWL_STYLE, style);

【问题讨论】:

  • But they don't work for me. 如果你能解释原因会有所帮助。
  • 能否展示相关代码(原生)
  • @DanWilson,我想在 wpf 中显示的窗口没有显示,并且“SetParent”返回 0。我已经搜索了更多信息,但这是我得到的唯一线索。

标签: c# wpf qt


【解决方案1】:

答案:external App inside WPF (notepad.exe works but others don't)。简而言之,这是不可能的,因为大多数应用都不支持 OLE。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-03-24
    • 1970-01-01
    • 1970-01-01
    • 2017-01-20
    • 1970-01-01
    • 1970-01-01
    • 2011-06-29
    相关资源
    最近更新 更多