Window title problem reading

Sep 3, 2014 at 1:07 AM
So, I use this:

[DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true, CallingConvention = CallingConvention.StdCall)]
    static extern int DrawTextExW(IntPtr hdc, [In, Out, MarshalAs(UnmanagedType.LPTStr)] string lpString, int cchText, [In, Out, MarshalAs(UnmanagedType.Struct)] ref RECT lprc, uint dwDTFormat, [In, Out, MarshalAs(UnmanagedType.Struct)] ref DRAWTEXTPARAMS dparams);
When window title fits to title bar, everything is ok, but when it doesn't fit, then I get example:
Table11 Something 1324489679...
and it should be
Table11 Something 132448967925 And something else

Any help would be great. Thank You!
Sep 3, 2014 at 9:36 AM
This is the text that is being drawn, so that is why the truncation. You will need to trace the call back further to find where you can grab the raw text.

Sep 3, 2014 at 11:41 AM
Thank You spazzarama!

I tryed this:
StringBuilder title = new StringBuilder(256);
                GetWindowText(hdc, title, 256);
but I still get truncated text :(

Any hints please? :)

Thank You very much!
Sep 3, 2014 at 11:55 AM
How about if you hook SetWindowText and wait for the correct Hwnd? This would only work if you hook early enough tho.
Sep 3, 2014 at 1:36 PM
So if I understood good, I have to install hook to detect SetWindowText?

I install Draw hook like this:
                DrawTextExHook = LocalHook.Create(LocalHook.GetProcAddress("user32.dll", "DrawTextExW"), new DDrawTextEx(DrawText_Hooked), this);
                DrawTextExHook.ThreadACL.SetExclusiveACL(new Int32[] { 0 });
Sep 10, 2014 at 12:37 PM
Yes that is how you would go about installing the hook. Has that helped you find the text you are after?