Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
539 views
in Technique[技术] by (71.8m points)

c# - WinForms: Maximum Size of a Control is 65535 - Workaround?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...