1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
using System;
using System.Diagnostics;
using System.Windows.Forms;
public class Program
{
private static CommandLineWindow s_Window = new CommandLineWindow();
[STAThread()]
public static void Main(String[] args)
{
using(OpenFileDialog ofd = new OpenFileDialog())
{
//funktioniert nicht:
//ofd.ShowDialog();
//funktioniert:
ofd.ShowDialog(s_Window);
}
}
}
internal class CommandLineWindow : IWin32Window
{
#region IWin32Window Members
public IntPtr Handle
{
get
{
return (Process.GetCurrentProcess().MainWindowHandle);
}
}
#endregion
}
|