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);
            }
      
  • 相关阅读:
    configbody
    add log to ldap
    registerComponent announceExist
    ldap
    6485 commands
    Titled Motor Entry
    ldap pkg
    remove rpm pkg
    创建自定义验证控件,以验证多行文本框中内容长度为例
    ASP.NET利用CustomValidator的ClientValidationFunction与OnServerValidate来double check资料输入的正确性
  • 原文地址:https://www.cnblogs.com/z45281625/p/10935356.html
Copyright © 2011-2022 走看看