From 004a6ef92cf435c7cceb346a1cbdec8bf2cabea4 Mon Sep 17 00:00:00 2001 From: ttp Date: Mon, 23 Nov 2009 20:16:36 +0900 Subject: [PATCH] =?utf8?q?AppliStation-GUI,=E3=83=98=E3=83=83=E3=83=80?= =?utf8?q?=E9=83=A8=E3=82=92=E5=8F=B3=E3=82=AF=E3=83=AA=E3=83=83=E3=82=AF?= =?utf8?q?=E3=81=97=E3=81=9F=E3=81=A8=E3=81=8D=E3=81=AE=E5=8B=95=E4=BD=9C?= =?utf8?q?=E3=82=92=E5=A4=89=E6=9B=B4=E3=81=97=E3=80=81=E3=82=B3=E3=83=A9?= =?utf8?q?=E3=83=A0=E8=A1=A8=E7=A4=BA=E3=81=AA=E3=81=A9=E3=81=AE=E3=83=A1?= =?utf8?q?=E3=83=8B=E3=83=A5=E3=83=BC=E3=81=8C=E8=A1=A8=E7=A4=BA=E3=81=95?= =?utf8?q?=E3=82=8C=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F?= =?utf8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- AppliStation/AppliStation.Util/NativeMethods.cs | 33 +++++++++++++++++++++++++ AppliStation/PackageListViewForm.cs | 18 ++++++++++++-- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/AppliStation/AppliStation.Util/NativeMethods.cs b/AppliStation/AppliStation.Util/NativeMethods.cs index 5d46eb6..2bd8d06 100644 --- a/AppliStation/AppliStation.Util/NativeMethods.cs +++ b/AppliStation/AppliStation.Util/NativeMethods.cs @@ -214,6 +214,28 @@ namespace AppliStation.Util } } + /// + /// ヘッダ部のサイズを返す + /// + /// ListView + /// ヘッダ部のクライアントサイズ + public static Size ColumnHeader_GetSize(ListView listView) + { + LRECT lrect; + + try { + // SendMessage(hWnd, LVM_GETHEADER, NULL, NULL); + IntPtr hWnd = SendMessage(listView.Handle, 0x101F, IntPtr.Zero, IntPtr.Zero); + GetClientRect(hWnd, out lrect); + } catch { + lrect.Left = lrect.Right = lrect.Top = lrect.Bottom = 0; + } + + Size size = new Size(lrect.Right - lrect.Left, + lrect.Bottom - lrect.Top); + return size; + } + #endregion #endregion @@ -396,5 +418,16 @@ namespace AppliStation.Util [DllImport("uxtheme.dll", ExactSpelling=true, CharSet=CharSet.Unicode)] internal static extern int SetWindowTheme(IntPtr hWnd, String pszSubAppName, String pszSubIdList); + [Serializable] + [StructLayout(LayoutKind.Sequential)] + private struct LRECT { + public int Left; + public int Top; + public int Right; + public int Bottom; + } + + [DllImport("user32.dll")] + private static extern bool GetClientRect(IntPtr hWnd, out LRECT lpRect); } } diff --git a/AppliStation/PackageListViewForm.cs b/AppliStation/PackageListViewForm.cs index 4a5b13d..9433fab 100644 --- a/AppliStation/PackageListViewForm.cs +++ b/AppliStation/PackageListViewForm.cs @@ -521,8 +521,22 @@ namespace AppliStation bool selectionIsOnlyOne = packageListView.SelectedItems.Count == 1; bool hasSelection = packageListView.SelectedItems.Count > 0; - // インストール先のフォルダの設定 - updateLauncherMenuItem(installedDirectoryToolStripMenuItem); + updateSelectedPackages(); + + if (packageListView.View == View.Details) { + // ヘッダ部がクリックされたとき、パッケージが選択されていないものとして扱って処理をする。 + int headerHeight = AppliStation.Util.NativeMethods.ColumnHeader_GetSize(packageListView).Height; + if (packageListView.PointToClient(packageListContextMenuStrip.Location).Y < headerHeight) { + selectionIsOnlyOne = hasSelection = false; + installToolStripMenuItem.Visible = false; + uninstallToolStripMenuItem.Visible = false; + } + } + + if (selectionIsOnlyOne) { + // インストール先のフォルダの設定 + updateLauncherMenuItem(installedDirectoryToolStripMenuItem); + } packageListContextMenuStripSeparator.Visible = selectionIsOnlyOne; webResourceToolStripMenuItem.Visible = selectionIsOnlyOne; -- 2.11.0