zoukankan      html  css  js  c++  java
  • 在窗体中嵌入 应用程序

    //在窗体中嵌入应用程序
    //show
       Process process = null;
            IntPtr appWin;
            private string exeName = "";
    
            [DllImport("user32.dll", SetLastError = true)]
            private static extern long SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
    
    
            [DllImport("user32.dll", SetLastError = true)]
            private static extern bool MoveWindow(IntPtr hwnd, int x, int y, int cx, int cy, bool repaint);
    private void button1_Click(object sender, EventArgs e)
            {
                this.exeName = IniHelper.IniData.VideoUrl.pathvalue;
                try
                {
                    // Start the process
                    process = System.Diagnostics.Process.Start(this.exeName);
                    // Wait for process to be created and enter idle condition
                    process.WaitForInputIdle();
    
                    // Get the main handle
                    appWin = process.MainWindowHandle;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, ex.Message, "Error");
                }
                // Put it into this form
                SetParent(appWin, this.Handle);
                // Remove border and whatnot
                // SetWindowLong(appWin, GWL_STYLE, WS_VISIBLE);
                // Move the window to overlay it on this window
                MoveWindow(appWin, 0, 0, this.Width, this.Height, true);
            }
            private void Form2_FormClosed(object sender, FormClosedEventArgs e)
            {
                try
                {
                    process.Kill();
                }
                catch { }
            }
            private void Form2_Resize(object sender, EventArgs e)
            {
                if (this.appWin != IntPtr.Zero)
                {
                    MoveWindow(appWin, 0, 0, this.Width, this.Height, true);
                }
                //base.OnResize(e);
            }
      
  • 相关阅读:
    Faster R-CNN
    06.看板实践——限制在制品
    05.看板方法——在制品
    04.看板实践——工作项
    03.看板实战——工作可视化
    02.看板实践——理解看板
    01.看板实践——学习看板(笔记)
    00.看板实践——前言(笔记)
    00.Scrum指南
    02.有效的项目管理——什么是项目管理
  • 原文地址:https://www.cnblogs.com/z45281625/p/10935356.html
Copyright © 2011-2022 走看看