When it is harder to fit your calendar into things than things into your calendar

by Michael S. Kaplan, published on 2007/08/30 03:01 -04:00, original URI: http://blogs.msdn.com/b/michkap/archive/2007/08/30/4639083.aspx


Support Engineer Scott Heim had a question he asked yesterday:

Hi all,

I have the MonthCalendar control on a form and when this is displayed in XP, the calendar displays correctly; however, on Vista machines the calendar appears larger and the “Saturday” dates are cut off. Has anyone seen this before? Is there a way around this?

The form the control is on is not much larger than the control itself. I have a small repro here:

[I compiled the repro and ran it on both Server 2003 and Vista to take the screen shots below -- michkap]

     

Thanks,

Scott

And support engineer Dave Anderson came to the rescue with the following response:

Yes, the MonthCalendar control is larger when using the V6 common controls on Windows Vista. You can adjust the size of the form based on the size of the control at runtime. I added the following code for the form’s Load event handler:

        private void Form1_Load(object sender, EventArgs e)
        {
            this.ClientSize = monthCalendar1.PreferredSize;
        }

-Dave

And indeed, when you add this code things fit once again:

Perfect. :-)

Now obviously this is a special case (a form that is meant to be the same size as the calendar) but the general principle can be applied in situations where controls are packed too tightly and changing the size might affect localized form by causing controls to overlap (definitely something to avoid).

One thing developers should be very careful about any time they are building dynamic UI metrics this way in projects that are going to be localized is to make sure that the fact that the UI metrics change at runtime is communicated to the localizer -- there are few things more frustrating than truncation bugs that a localizer can't do anything about but that they have to go through multiple iterations to discover that fact!

And now that I have hijacked the question to get up on my localizability soapbox, I'll close with a message of more general use. :-)

The messge? The fact that the Shell common controls do not guarantee backward compatibility with their metrics is an important issue to keep in mind -- or you could find yourself getting truncated, too....

 

This post brought to you by (U+2ea6, a.k.a. CJK RADICAL SIMPLIFIED HALF TREE TRUNK)


no comments

Please consider a donation to keep this archive running, maintained and free of advertising.
Donate €20 or more to receive an offline copy of the whole archive including all images.

go to newer or older post, or back to index or month or day