Während mein Programm ausgeführt wird, ich will Microsoft Speech Recognition Anwendung verstecken/minimieren:Wie verberge/zeige ich einen Prozess mit C#?
alt text http://img143.imageshack.us/img143/9380/minimize.png
und am Ende möchte ich mit C# zeigen/maximieren!
Dieser Prozess wird von mir nicht gestartet, daher kann ich den Prozess startInfo nicht steuern.
Ich habe versucht, user32.dll Methoden zu verwenden, wie zum Beispiel:
- Showwindow
- AnimatedWindows
- AnimatedWindows
- SetForegroundWindow
- SetWindowPos
Mit alle von ihnen Ich habe das gleiche Problem.
Ich kann die Fenster verstecken (althought Ich habe eine der Methoden, zweimal mit SW_HIDE Option nennen), aber wenn ich die Methode mit einem SW_SHOW Flag nennen, tut es einfach nicht zeigt ..
Wie Kann ich nach dem Verstecken des Prozesses maximieren/anzeigen?
Vielen Dank im Voraus!
{
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetWindowPlacement(IntPtr hWnd, ref WINDOWPLACEMENT lpwndpl);
[DllImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool SetWindowPlacement(IntPtr hWnd,
[In] ref WINDOWPLACEMENT lpwndpl);
[DllImport("user32.dll")]
public static extern Boolean ShowWindowAsync(IntPtr hWnd, Int32 nCmdShow);
[DllImport("user32.dll")]
public static extern Boolean SetForegroundWindow(IntPtr hWnd);
[DllImport("user32.dll")]
public static extern Boolean ShowWindow(IntPtr hWnd, Int32 nCmdShow);
[DllImport("user32.dll")]
public static extern Boolean AnimateWindow(IntPtr hWnd, uint dwTime, uint dwFlags);
[DllImport("dwmapi.dll")]
public static extern int DwmSetWindowAttribute(IntPtr hwnd, uint dwAttribute, IntPtr pvAttribute, IntPtr lol);
//Definitions For Different Window Placement Constants
const UInt32 SW_HIDE = 0;
const UInt32 SW_SHOWNORMAL = 1;
const UInt32 SW_NORMAL = 1;
const UInt32 SW_SHOWMINIMIZED = 2;
const UInt32 SW_SHOWMAXIMIZED = 3;
const UInt32 SW_MAXIMIZE = 3;
const UInt32 SW_SHOWNOACTIVATE = 4;
const UInt32 SW_SHOW = 5;
const UInt32 SW_MINIMIZE = 6;
const UInt32 SW_SHOWMINNOACTIVE = 7;
const UInt32 SW_SHOWNA = 8;
const UInt32 SW_RESTORE = 9;
public sealed class AnimateWindowFlags
{
public const int AW_HOR_POSITIVE = 0x00000001;
public const int AW_HOR_NEGATIVE = 0x00000002;
public const int AW_VER_POSITIVE = 0x00000004;
public const int AW_VER_NEGATIVE = 0x00000008;
public const int AW_CENTER = 0x00000010;
public const int AW_HIDE = 0x00010000;
public const int AW_ACTIVATE = 0x00020000;
public const int AW_SLIDE = 0x00040000;
public const int AW_BLEND = 0x00080000;
}
public struct WINDOWPLACEMENT
{
public int length;
public int flags;
public int showCmd;
public System.Drawing.Point ptMinPosition;
public System.Drawing.Point ptMaxPosition;
public System.Drawing.Rectangle rcNormalPosition;
}
//this works
param = new WINDOWPLACEMENT();
param.length = Marshal.SizeOf(typeof(WINDOWPLACEMENT));
param.showCmd = (int)SW_HIDE;
lol = SetWindowPlacement(theprocess.MainWindowHandle, ref param);
// this doesn't work
WINDOWPLACEMENT param = new WINDOWPLACEMENT();
param.length = Marshal.SizeOf(typeof(WINDOWPLACEMENT));
param.showCmd = SW_SHOW;
lol = GetWindowPlacement(theprocess.MainWindowHandle, ref param);
HINWEIS: Ist der SAPI API einen Befehl dies das Fenster verkleinern und zu maximieren, zu minimieren hat
Hier einige Stücke des Codes sind, jetzt verwenden SetWindowPlacement umgesetzt?
ich, dass man Mension vergessen. Ich habe das auch benutzt! –
aktualisiert zu sein. – hawk