OSDN Git Service

リストが横スクロールされていても正しい位置にアイコンを描画するように修正
authoranis774 <anis774@users.sourceforge.jp>
Tue, 7 Sep 2010 23:12:54 +0000 (23:12 +0000)
committerKimura Youichi <kim.upsilon@bucyou.net>
Sat, 18 Feb 2012 14:15:16 +0000 (23:15 +0900)
git-svn-id: http://svn.sourceforge.jp/svnroot/tween/trunk@826 e39ad16e-3079-482e-bb30-4b4d378143b6

Tween/Tween.vb

index 61787b7..2d1e82e 100644 (file)
@@ -3821,21 +3821,37 @@ Public Class TweenMain
                     fnt.Dispose()
                 End If
             End If
+
+            If _iconSz > 0 AndAlso Math.Abs(e.Header.DisplayIndex - e.Item.ListView.Columns(0).DisplayIndex) = 1 Then
+                If Not String.IsNullOrEmpty(e.Item.ImageKey) Then
+                    Me.DrawListViewItemIcon(e)
+                End If
+            End If
         Else
             If _iconSz > 0 Then
                 If Not String.IsNullOrEmpty(e.Item.ImageKey) Then
-                    'e.Bounds.Leftが常に0を指すから自前で計算
-                    Dim x As Integer = e.Item.GetBounds(ItemBoundsPortion.Icon).X
-
-                    If tw.DetailIcon.ContainsKey(e.Item.ImageKey) Then
-                        e.Graphics.InterpolationMode = Drawing2D.InterpolationMode.High
-                        e.Graphics.DrawImage(tw.DetailIcon(e.Item.ImageKey), New Rectangle(x, e.Bounds.Top, Math.Min(_iconSz, e.Bounds.Width), _iconSz))
-                    End If
+                    Me.DrawListViewItemIcon(e)
                 End If
             End If
         End If
     End Sub
 
+    Private Sub DrawListViewItemIcon(ByVal e As DrawListViewSubItemEventArgs)
+        'e.Bounds.Leftが常に0を指すから自前で計算
+        Dim x As Integer = e.Item.ListView.GetItemRect(e.ItemIndex).X
+
+        For Each clm As ColumnHeader In e.Item.ListView.Columns
+            If clm.DisplayIndex < e.Item.ListView.Columns(0).DisplayIndex Then
+                x += clm.Width
+            End If
+        Next
+
+        If tw.DetailIcon.ContainsKey(e.Item.ImageKey) Then
+            e.Graphics.InterpolationMode = Drawing2D.InterpolationMode.High
+            e.Graphics.DrawImage(tw.DetailIcon(e.Item.ImageKey), New Rectangle(x, e.Bounds.Top, Math.Min(_iconSz, e.Item.ListView.Columns(0).Width), _iconSz))
+        End If
+    End Sub
+
     Private Sub DoTabSearch(ByVal _word As String, _
                             ByVal CaseSensitive As Boolean, _
                             ByVal UseRegex As Boolean, _