In WinForms and C#, it seems I cannot create a control wider than 65535. If I set it to 70.000, the value gets reset to 65535. Digging through the source of Control.Size with ILSpy, I couldn't immediately find the code responsible for clamping the size.
So is this a limit of the Win32 API or of Windows Forms? Is there any way around this, e.g. with unmanaged interop?
The reason I need such a large control is that I draw music waveform of very long audio files onto it. (Yes, I could draw the waveform directly, without a containing control; but that would require lots of refactoring). I am not talking about the drawing code here. Clearly it's necessary to draw only the visible part, but the thing is that I'd like to have a control as wide as 200.000 pixels.
It is a winapi restriction. A pretty hard one, the mouse position is reported with, say, the WM_MOUSEMOVE message with the mouse position packed into the LPARAM argument. With 16 bits for the X- and 16-bits for Y-location.
You'll have to deal with it. It is not a limitation on for example the AutoScrollMinSize property of a panel. Which is what you'd always use in this case anyway, start painting at AutoScrollPosition.
I do think its a limitation of windows forms, the thing is, for your needs a WPF form would be more suitable as it allows larger loads. Just my opinion.
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