2016-07-28 9 views
0

저의 폼 위에 신청서 (메모장)를 열어 주시겠습니까?상단에 mys 폼으로 노트 패드를 엽니 다

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

시도해 보았지만 올바르지 않습니다. 그럼 어떻게하면 ShowDialog처럼 notepad.exe 나 word.exe를 내 양식 위에 열 수 있습니까?

코디 얼리

답변

0

SetForegroundWindow function을 사용하십시오.

using System.Runtime.InteropServices;를 선언하고 사용

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

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