Created WPF application in VS2015. Set the Window's title to a string of length 290.
Title = "123456789 223456789 323456789 423456789 523456789 623456789 723456789 823456789 923456789 133456789 233456789 333456789 433456789 533456789 633456789 733456789 833456789 933456789 143456789 243456789 343456789 443456789 543456789 643456789 743456789 843456789 943456789 153456789 253456789 ";
When the application is run, the title is truncated to 255 characters (maximised window and window extended across 2 screens).
I tried
It seems that 255 chars is an internal limitation in the DefWindowProc()
native window function.
WPF changes the windows's title using a call to a native method:
UnsafeNativeMethods.SetWindowText(new HandleRef(this, CriticalHandle), title);
This method accepts strings of any length, so that should actually work. This is not a WPF problem.
But...
Even if you create a standard and native Win32 window that uses the DefWindowProc()
function, you will observe the same behavior - maximum 255 characters in the window title.
Windows paints the title bar in response to a WM_NCPAINT
message (along with the window frames, the system button, and so on). Inside the DefWindowProc()
code that handles WM_NCPAINT
messages, the code calls GetWindowText()
to get the window's title string. In this call to GetWindowText()
, the size of the buffer seems to be 255 chars (in old Windows, the buffer was only 79 bytes). This limits the length of a window's title to 255 characters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With