using the GetWindowText function I am trying to get the Window Caption using C# of an error message. I am able to get the Window Caption of every button in the dialogue but not the text of the label. Using Spy++ I identified the dialogue and the Window Caption field is filled with the message in the label of the dialogue but GetWindowText of this Window Handle gives me an empty string. Compared to the button Window Handle, which gives me the a string with the Window Caption. This is the code I use:
string nameOfStuff = "";
StringBuilder lpClassName = new StringBuilder();
int index = 20;
int ct = 0;
IntPtr result = IntPtr.Zero;
do
{
result = FindWindowEx(appHandle, result, null, null);
if (result != IntPtr.Zero)
{
GetWindowText(result, lpClassName, 100);
nameOfStuff += " " + Convert.ToString(ct) + lpClassName.ToString() + "\n";
++ct;
}
}
while (ct < index && result != IntPtr.Zero);
This code gives me all the Window Captions except the one from the label. Here is how the Spy++ looks like:
Any idea why I can't get the Window Caption of the label in such a way? Thanks!