このメニューを Win7 の C# または F# で使用したいと考えています。呼び方すらわかりませんでした。
1 に答える
MSDN マガジンの「Introduction The Taskbar APIs」では、サムネイル ツールバーの使用方法について説明しています。
同等のマネージは、現在 Windows API Code Pack には表示されませんが、将来のリリースで表示される予定です。それまでの間、Windows 7 タスクバー相互運用サンプル ライブラリを使用できます。これには、サムネール ツールバーを制御するための対応する CreateThumbButton および AddThumbButtons メソッドを含む ThumbButtonManager クラスと、実行時にサムネール ボタンの状態を変更するための ThumbButton クラスが含まれます。通知を受け取るには、ThumbButton.Clicked イベントを登録し、ウィンドウ プロシージャをオーバーライドしてメッセージを ThumbButtonManager クラスにディスパッチします。(詳細については、ブログ記事「Windows 7 タスクバー: サムネイル ツールバー」を参照してください。 )
ITaskbarList3* ptl;//Created earlier //In your window procedure:
switch (msg) {
case g_wmTBC://TaskbarButtonCreated
THUMBBUTTON buttons[2]; buttons[0].dwMask = THB_ICON|THB_TOOLTIP|THB_FLAGS; buttons[0].iId = 0;
buttons[0].hIcon = GetIconForButton(0); wcscpy(buttons[0].szTip, L"Tooltip 1"); buttons[0].dwFlags = THBF_ENABLED;
buttons[1].dwMask = THB_ICON|THB_TOOLTIP|THB_FLAGS;
buttons[1].iId = 1; buttons[1].hIcon = GetIconForButton(1);
wcscpy(buttons[0].szTip, L"Tooltip 2"); buttons[1].dwFlags = THBF_ENABLED; VERIFY(ptl->ThumbBarAddButtons(hWnd, 2,buttons));
break;
case WM_COMMAND:
if (HIWORD(wParam) == THBN_CLICKED) {
if (LOWORD(wParam) == 0)
MessageBox(L"Button 0 clicked", ...);
if (LOWORD(wParam) == 1) MessageBox(L"Button 1 clicked", ...);
}
break;
.
.
2 番目のリンクでは、ラッパー ライブラリを使用した C# サンプルを示しています。
いつものように、管理されたラッパーが助けになります。ThumbButtonManager クラス (Windows7.DesktopIntegration プロジェクト内)
_thumbButtonManager = this.CreateThumbButtonManager();
ThumbButton button2 = _thumbButtonManager.CreateThumbButton(102, SystemIcons.Exclamation, "Beware of me!");
button2.Clicked += delegate
{
statusLabel.Text = "Second button clicked";
button2.Enabled = false;
};
ThumbButton button = _thumbButtonManager.CreateThumbButton(101, SystemIcons.Information, "Click me");
button.Clicked += delegate
{
statusLabel.Text = "First button clicked";
button2.Enabled = true;
};
_thumbButtonManager.AddThumbButtons(button, button2);
Note that you have tooltips and icons at your disposal to personalize the thumbnail toolbar to your application’s needs. All you need to do now is override your windows’ window procedure and call the DispatchMessage method of the ThumbButtonManager, so that it can correctly route the event to your registered event handlers (and of course, don’t forget to call the default window procedure when you’re done!):
if (_thumbButtonManager != null)
_thumbButtonManager.DispatchMessage(ref m);
base.WndProc(ref m);