【问题标题】:Restoring parent from the desktop window从桌面窗口恢复父级
【发布时间】:2018-08-19 13:33:39
【问题描述】:

我已经导入:

public static extern IntPtr SetParent(
        IntPtr hWndChild,      // handle to window
        IntPtr hWndNewParent   // new parent window
    );

来自我的 Windows 窗体应用程序中的user32.dll,并在后台线程中不断设置SetParent(hwndf,hwndParent);(如果变量为真)。

在哪里

IntPtr hwndf = Control.Handle;
IntPtr hwndParent = FindWindow("ProgMan", null);

我的问题如何将父句柄重置为默认的窗体句柄,也就是我如何不再在桌面窗口顶部显示窗口? 并且正在关注,这是一种有效的方法(重复?)。

【问题讨论】:

    标签: c# .net window desktop handle


    【解决方案1】:

    没关系。我可以使用

    SetParent(hwndf, new IntPtr(0));
    

    当我想“重置”表单窗口父级时。唯一的问题是窗口被最小化了,所以我的解决方案在从user32.dll 导入这些方法后运行ShowWindow(hwndf, SW_RESTORE);

        [DllImport("user32.dll")]
        public static extern IntPtr ShowWindow(
            IntPtr hWnd,      // handle to window
            uint nCmdShow
        );
        private const uint SW_RESTORE = 0x09;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-07
      • 2021-03-09
      • 1970-01-01
      相关资源
      最近更新 更多