質問

ウィンドウは、システムトレイに、タスクバーに表示されません。どのように私はそれは同様タスクバーに表示することができますか?

私は、次のコードを試してみましたが、それは効果がありませんでした:

int windowStyle = GetWindowLong(pMainWindow, GWL_EXSTYLE);
SetWindowLong(pMainWindow, GWL_EXSTYLE, windowStyle & WS_EX_TOOLWINDOW);

そして、これは私のフォームではありません!私はProcess.GetProcessesByNameからハンドルを取得していると私は、Formクラスのプロパティにアクセスする方法がわからない。

Process[] processes = Process.GetProcessesByName("somename");
someProcess = processes[0];

pMainWindow = someProcess.MainWindowHandle;
役に立ちましたか?

解決

以下は、トリックを行うようです。あなたがそれをSetWindowLong関数呼び出した後にウィンドウを非表示&再表示した場合、その後、タスクバーに表示されます。

私は、ウィンドウが最小化された後、タスクバーから削除する方法を見つけるのに苦労しています...

[DllImport("User32.Dll")]                
public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);

[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

private const int SW_HIDE = 0x00;
private const int SW_SHOW = 0x05;

private const int WS_EX_APPWINDOW = 0x40000;
private const int GWL_EXSTYLE = -0x14;

private void ShowWindowInTaskbar(IntPtr pMainWindow)
{                       
    SetWindowLong(pMainWindow, GWL_EXSTYLE, WS_EX_APPWINDOW);

    ShowWindow(pMainWindow, SW_HIDE);
    ShowWindow(pMainWindow, SW_SHOW);      
}
scroll top