Control Width and Height limited to 32,767 pixels

G

Guest

Why are controls limited to 32,767 pixels? The width and Height properties
are supposed to be 32-bit integers. I am trying to make a timeline control
that could be scalled out to a unit increment of 0.01 seconds per grid
division (each grid division is 50 pixels) and have a total timeline of 10
minutes. This means my Control must be able to be at least 3,000,000 pixels
wide.
Whats strange is that the controls were sizing properly earlier today, but
all of a sudden, for some reason I can't explain, this limitation has
suddenly been introduced.

Can somebody please help me understand this!?

I have done some browsing around, and I saw that it was a reported bug on
some websites ie:
Item #20 on these websites
http://www.jelovic.com/dotnetbugs/

I'm not sure if this is considered a bug by Microsoft - I can't find any
mention about it anywhere else.

Is there a way (preprocessor directive, or optimization setting) to force
the compiler to use 32-bit integers for these fields? I really don't
understand why it WAS working earlier if this is a "built-in" limitation of
Control.Width and Control.Height.

Just as background, my timeline controls are extending UserControl. When
the user scales (zooms) in to the control, I specify the size of the control
to be:

Timeline.Width = MAXIMUM_TIME * ( GRID_INCREMENT / ( scale * 100.0f ) ) ;

where MAXIMUM_TIME is the maximum length of the timeline in centiseconds,
GRID_INCREMENT is the distance in pixels between units, and scale is the
"zoom level" of the timeline - the lowest zoom level is 0.01.

At the lowest zoom and a timeline of 10min, this would generate a width of
3,000,000 pixels.

Any ideas on whats going on? Or how I can get around this?
 
C

Chris Dunaway

Jeremiah said:
Why are controls limited to 32,767 pixels? The width and Height properties
are supposed to be 32-bit integers. I am trying to make a timeline control

It may be that the limitation is not the .Net framework, but in Windows
itself.
At the lowest zoom and a timeline of 10min, this would generate a width of
3,000,000 pixels.

Any ideas on whats going on? Or how I can get around this?

Since the user's screen will never show that many pixels across, you
could modify your paint routine to only paint a portion of that. Then
as the scroll right and left in the timeline, you only paint the
visible portion.
 
G

Guest

Thanks for your suggestion. The problem with that is that I then have to
implement a custom scroll bar and I won't be able to use the AutoScroll
feature of the parent panel. This is the long way around and I did think of
this.. but my timeline has to be done in 24 hours and I was hoping there was
a faster way around this issue. Well, I guess it's going to be a long
night...

Any suggestions on implementing a "virtual plane"? (The control maintains
the size of the parent panel, but the contents are painted relative to some
scrolling tool - not necessarily a scroll bar). This will allow for a
virtually infinite drawing surface.
 
B

Bob Powell [MVP]

Did you read the Understanding Autoscroll article in Windows Forms Tips and
Tricks and the article on how to backtrack the mouse?

All the principles you need are clearly outlined there.

If you need more help I take plastic ;-) If your e-mail wasn't bogus I'd
propose a couple of hours consulting in private but as it's not...

<blatant commercialism>
I can provide you with a full virtual canvas with mouse interaction for 3-4
hours work. As you're in the US say yes and it'll be ready for 9:00 AM your
time tomorrow morning.
</blatant commercialism>

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top