2016-07-28 30 views
0

Können Sie mir bitte eine Anwendung (Notizblock) oben auf meinem Formular öffnen?Öffnen Sie das NotePad in mystischer Form oben

private void button1_Click(object sender, EventArgs e) 
    { 
     Process N = new Process.Start(@"notepad.exe"); 
     N.ShowDialog(this); 
    } 

Ich versuche das, ist aber nicht korrekt. Also, wie kann ich Notepad.exe oder Word.exe auf meinem Formular als ShowDialog bitte öffnen?

Herzlich

Antwort

0

Verwendung SetForegroundWindow function.

Deklarieren using System.Runtime.InteropServices; und verwenden

[DllImport("user32.dll")] 
static extern bool SetForegroundWindow(IntPtr hWnd); 

private void SetNotepadAsForegroundApp() 
{ 
    Process N = new Process.Start(@"notepad.exe"); 
    SetForegroundWindow(N.MainWindowHandle); 
}