[Mwinapi-commits] SF.net SVN: mwinapi:[112] trunk/ManagedWinapi
Status: Beta
Brought to you by:
schierlm
|
From: <sch...@us...> - 2012-04-20 16:25:05
|
Revision: 112
http://mwinapi.svn.sourceforge.net/mwinapi/?rev=112&view=rev
Author: schierlm
Date: 2012-04-20 16:24:56 +0000 (Fri, 20 Apr 2012)
Log Message:
-----------
- Detect ListView/TreeView by ClassName if empty
- Speed up ListView grabbing by caching the SystemWindow.Process object
[thanks to Yusufi Bharmal for the suggestions]
Modified Paths:
--------------
trunk/ManagedWinapi/Contents/ListParser.cs
trunk/ManagedWinapi/SystemListView.cs
trunk/ManagedWinapi/SystemTreeView.cs
trunk/ManagedWinapi/SystemWindow.cs
Modified: trunk/ManagedWinapi/Contents/ListParser.cs
===================================================================
--- trunk/ManagedWinapi/Contents/ListParser.cs 2012-01-03 21:56:22 UTC (rev 111)
+++ trunk/ManagedWinapi/Contents/ListParser.cs 2012-04-20 16:24:56 UTC (rev 112)
@@ -206,14 +206,14 @@
{
uint LVM_GETITEMCOUNT = (0x1000 + 4);
int cnt = sw.SendGetMessage(LVM_GETITEMCOUNT);
- return cnt != 0;
+ return cnt != 0 || sw.ClassName == "SysListView32";
}
internal override WindowContent ParsePreviewContent(SystemWindow sw)
{
uint LVM_GETITEMCOUNT = (0x1000 + 4);
int cnt = sw.SendGetMessage(LVM_GETITEMCOUNT);
- if (cnt == 0) throw new Exception();
+ if (cnt == 0 && sw.ClassName != "SysListView32") throw new Exception();
SystemAccessibleObject o = SystemAccessibleObject.FromWindow(sw, AccessibleObjectID.OBJID_CLIENT);
if (o.RoleIndex == 33)
{
@@ -229,7 +229,7 @@
{
uint LVM_GETITEMCOUNT = (0x1000 + 4);
int cnt = sw.SendGetMessage(LVM_GETITEMCOUNT);
- if (cnt == 0) throw new Exception();
+ if (cnt == 0 && sw.ClassName != "SysListView32") throw new Exception();
try
{
SystemListView slv = SystemListView.FromSystemWindow(sw);
@@ -410,7 +410,7 @@
internal override bool CanParseContent(SystemWindow sw)
{
int cnt = sw.SendGetMessage(TVM_GETCOUNT, 0);
- return cnt != 0;
+ return cnt != 0 || sw.ClassName == "SysTreeView32";
}
internal override WindowContent ParsePreviewContent(SystemWindow sw)
Modified: trunk/ManagedWinapi/SystemListView.cs
===================================================================
--- trunk/ManagedWinapi/SystemListView.cs 2012-01-03 21:56:22 UTC (rev 111)
+++ trunk/ManagedWinapi/SystemListView.cs 2012-04-20 16:24:56 UTC (rev 112)
@@ -36,7 +36,7 @@
/// </summary>
public static SystemListView FromSystemWindow(SystemWindow sw)
{
- if (sw.SendGetMessage(LVM_GETITEMCOUNT) == 0) return null;
+ if (sw.SendGetMessage(LVM_GETITEMCOUNT) == 0 && sw.ClassName != "SysListView32") return null;
return new SystemListView(sw);
}
Modified: trunk/ManagedWinapi/SystemTreeView.cs
===================================================================
--- trunk/ManagedWinapi/SystemTreeView.cs 2012-01-03 21:56:22 UTC (rev 111)
+++ trunk/ManagedWinapi/SystemTreeView.cs 2012-04-20 16:24:56 UTC (rev 112)
@@ -36,7 +36,7 @@
/// </summary>
public static SystemTreeView FromSystemWindow(SystemWindow sw)
{
- if (sw.SendGetMessage(TVM_GETCOUNT) == 0) return null;
+ if (sw.SendGetMessage(TVM_GETCOUNT) == 0 && sw.ClassName != "SysTreeView32") return null;
return new SystemTreeView(sw);
}
Modified: trunk/ManagedWinapi/SystemWindow.cs
===================================================================
--- trunk/ManagedWinapi/SystemWindow.cs 2012-01-03 21:56:22 UTC (rev 111)
+++ trunk/ManagedWinapi/SystemWindow.cs 2012-04-20 16:24:56 UTC (rev 112)
@@ -786,6 +786,8 @@
return IsChild(ancestor._hwnd, _hwnd);
}
+ private Process _cachedProcess = null;
+
/// <summary>
/// The process which created this window.
/// </summary>
@@ -793,9 +795,13 @@
{
get
{
- int pid;
- GetWindowThreadProcessId(HWnd, out pid);
- return Process.GetProcessById(pid);
+ if (_cachedProcess == null)
+ {
+ int pid;
+ GetWindowThreadProcessId(HWnd, out pid);
+ _cachedProcess = Process.GetProcessById(pid);
+ }
+ return _cachedProcess;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|