[Mwinapi-commits] SF.net SVN: mwinapi:[78] trunk/ManagedWinapi
Status: Beta
Brought to you by:
schierlm
|
From: <sch...@us...> - 2009-01-17 14:29:01
|
Revision: 78
http://mwinapi.svn.sourceforge.net/mwinapi/?rev=78&view=rev
Author: schierlm
Date: 2009-01-17 14:28:47 +0000 (Sat, 17 Jan 2009)
Log Message:
-----------
Use WM_GETTEXT to receive text content of text boxes, which works better than GetWindowText.
Modified Paths:
--------------
trunk/ManagedWinapi/Contents/ListParser.cs
trunk/ManagedWinapi/Contents/TextFieldParser.cs
trunk/ManagedWinapi/SystemWindow.cs
Modified: trunk/ManagedWinapi/Contents/ListParser.cs
===================================================================
--- trunk/ManagedWinapi/Contents/ListParser.cs 2009-01-17 14:28:01 UTC (rev 77)
+++ trunk/ManagedWinapi/Contents/ListParser.cs 2009-01-17 14:28:47 UTC (rev 78)
@@ -184,7 +184,7 @@
{
values[i] = slb[i];
}
- return new ListContent("ComboBox", -1, sw.Title, values);
+ return new ListContent("ComboBox", -1, sw.Text, values);
}
}
@@ -340,7 +340,8 @@
{
List<string> treeNodes = new List<string>();
int selected = -1;
- foreach(SystemAccessibleObject n in sao.Children) {
+ foreach (SystemAccessibleObject n in sao.Children)
+ {
if (n.RoleIndex == 36)
{
if ((n.State & 0x2) != 0)
Modified: trunk/ManagedWinapi/Contents/TextFieldParser.cs
===================================================================
--- trunk/ManagedWinapi/Contents/TextFieldParser.cs 2009-01-17 14:28:01 UTC (rev 77)
+++ trunk/ManagedWinapi/Contents/TextFieldParser.cs 2009-01-17 14:28:47 UTC (rev 78)
@@ -104,13 +104,13 @@
}
else
{
- return sw.Title != "";
+ return sw.Text != "";
}
}
internal override WindowContent ParseContent(SystemWindow sw)
{
- return new TextContent(sw.Title, sw.PasswordCharacter != 0, strict);
+ return new TextContent(sw.Text, sw.PasswordCharacter != 0, strict);
}
}
}
Modified: trunk/ManagedWinapi/SystemWindow.cs
===================================================================
--- trunk/ManagedWinapi/SystemWindow.cs 2009-01-17 14:28:01 UTC (rev 77)
+++ trunk/ManagedWinapi/SystemWindow.cs 2009-01-17 14:28:47 UTC (rev 78)
@@ -508,6 +508,22 @@
}
/// <summary>
+ /// The text inside of this window (by sending a <c>WM_GETTEXT</c> message).
+ /// For child windows of other applications, this is more reliable
+ /// than the <see cref="Title"/> function.
+ /// </summary>
+ public string Text
+ {
+ get
+ {
+ int length = SendGetMessage(WM_GETTEXTLENGTH);
+ StringBuilder sb = new StringBuilder(length + 1);
+ SendMessage(new HandleRef(this, HWnd), WM_GETTEXT, new IntPtr(sb.Capacity), sb);
+ return sb.ToString();
+ }
+ }
+
+ /// <summary>
/// The name of the window class (by the <c>GetClassName</c> API function).
/// This class has nothing to do with classes in C# or other .NET languages.
/// </summary>
@@ -1306,7 +1322,7 @@
[DllImport("user32.dll")]
static extern IntPtr GetDC(IntPtr hWnd);
- private const int WM_CLOSE = 16;
+ private const int WM_CLOSE = 16, WM_GETTEXT = 13, WM_GETTEXTLENGTH = 14;
private enum GetWindow_Cmd
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|