回答編集履歴
1
見直しキャンペーン中
answer
CHANGED
@@ -1,40 +1,40 @@
|
|
1
|
-
どうしてそういう状態になるんでしょうね?(根深そうなので特に深入りしませんが^^;
|
1
|
+
どうしてそういう状態になるんでしょうね?(根深そうなので特に深入りしませんが^^;
|
2
|
-
|
2
|
+
|
3
|
-
そもそも余白のクリックを無視させるというアプローチがありました。
|
3
|
+
そもそも余白のクリックを無視させるというアプローチがありました。
|
4
|
-
[ListView Losing focus while clicking on blank space of listview in C#.net - CodeProject](https://www.codeproject.com/Questions/164806/ListView-Losing-focus-while-clicking-on-blank-spac)
|
4
|
+
[ListView Losing focus while clicking on blank space of listview in C#.net - CodeProject](https://www.codeproject.com/Questions/164806/ListView-Losing-focus-while-clicking-on-blank-spac)
|
5
|
-
|
5
|
+
|
6
|
-
`ListView`を`MyListView`に入れ替えます。
|
6
|
+
`ListView`を`MyListView`に入れ替えます。
|
7
|
-
コードの詳細は分かっていませんが、希望の動きになっていると思います。
|
7
|
+
コードの詳細は分かっていませんが、希望の動きになっていると思います。
|
8
|
-
|
8
|
+
|
9
|
-
```
|
9
|
+
```cs
|
10
|
-
using System.Drawing;
|
10
|
+
using System.Drawing;
|
11
|
-
using System.Windows.Forms;
|
11
|
+
using System.Windows.Forms;
|
12
|
-
|
12
|
+
|
13
|
-
namespace Questions346626
|
13
|
+
namespace Questions346626
|
14
|
-
{
|
14
|
+
{
|
15
|
-
public partial class MyListView : ListView
|
15
|
+
public partial class MyListView : ListView
|
16
|
-
{
|
16
|
+
{
|
17
|
-
public MyListView() => InitializeComponent();
|
17
|
+
public MyListView() => InitializeComponent();
|
18
|
-
|
18
|
+
|
19
|
-
protected override void WndProc(ref Message msg)
|
19
|
+
protected override void WndProc(ref Message msg)
|
20
|
-
{
|
20
|
+
{
|
21
|
-
// Ignore mouse messages not in the client area
|
21
|
+
// Ignore mouse messages not in the client area
|
22
|
-
if (msg.Msg >= 0x201 && msg.Msg <= 0x209)
|
22
|
+
if (msg.Msg >= 0x201 && msg.Msg <= 0x209)
|
23
|
-
{
|
23
|
+
{
|
24
|
-
var pointMousePos = new Point(msg.LParam.ToInt32() & 0xffff, msg.LParam.ToInt32() >> 16);
|
24
|
+
var pointMousePos = new Point(msg.LParam.ToInt32() & 0xffff, msg.LParam.ToInt32() >> 16);
|
25
|
-
var lvhti = HitTest(pointMousePos);
|
25
|
+
var lvhti = HitTest(pointMousePos);
|
26
|
-
switch (lvhti.Location)
|
26
|
+
switch (lvhti.Location)
|
27
|
-
{
|
27
|
+
{
|
28
|
-
case ListViewHitTestLocations.AboveClientArea:
|
28
|
+
case ListViewHitTestLocations.AboveClientArea:
|
29
|
-
case ListViewHitTestLocations.BelowClientArea:
|
29
|
+
case ListViewHitTestLocations.BelowClientArea:
|
30
|
-
case ListViewHitTestLocations.LeftOfClientArea:
|
30
|
+
case ListViewHitTestLocations.LeftOfClientArea:
|
31
|
-
case ListViewHitTestLocations.RightOfClientArea:
|
31
|
+
case ListViewHitTestLocations.RightOfClientArea:
|
32
|
-
case ListViewHitTestLocations.None:
|
32
|
+
case ListViewHitTestLocations.None:
|
33
|
-
return;
|
33
|
+
return;
|
34
|
-
}
|
34
|
+
}
|
35
|
-
}
|
35
|
+
}
|
36
|
-
base.WndProc(ref msg);
|
36
|
+
base.WndProc(ref msg);
|
37
|
-
}
|
37
|
+
}
|
38
|
-
}
|
38
|
+
}
|
39
|
-
}
|
39
|
+
}
|
40
40
|
```
|