Restrict size of Custom Task Pane

N

NickP

Hi there,

I have a custom task pane that I would like to restrict the size of,
i.e. only allow it to stretch to a certain height. It is currently
restricted to horizontal docking at the moment as it's width is not an
issue, but I want to try to prevent the user from stretching it above a
certain size.

TIA!.

Nick.
 
J

Jialiang Ge [MSFT]

Hello Nick,

From your post, my understanding on this issue is: you want to how to
restrict the size of a custom task pane when users stretch it. If I'm off
base, please feel free to let me know.

CustomTaskPane objects do not expose the properties like "MaximumSize".
CustomTaskPane.Control.MaximumSize also does not work because it just sets
the maximum size of internal custom control. When the panel is stretched,
the rest part of the panel will be left blank. A possible workaround that
performs well in my side is to capture the size-changed event of the custom
task pane and reset the size if it exceeds the maximum value. Please have a
try and let me know the result.

private Microsoft.Office.Tools.CustomTaskPane ctpCalendar = null;

private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
ctpCalendar = this.CustomTaskPanes.Add(new CalendarControl(), "Select a
date");
ctpCalendar.DockPosition =
Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionBottom;
ctpCalendar.Visible = true;
ctpCalendar.Height = 200;

ctpCalendar.Control.SizeChanged += new
EventHandler(Control_SizeChanged);
}
void Control_SizeChanged(object sender, EventArgs e)
{
if (ctpCalendar.Height > 300)
ctpCalendar.Height = 300;
}

If you have any other concern or need anything else, please feel free to
let me know.

Sincerely,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
For MSDN subscribers whose posts are left unanswered, please check this
document: http://blogs.msdn.com/msdnts/pages/postingAlias.aspx

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express/Windows Mail, please make sure
you clear the check box "Tools/Options/Read: Get 300 headers at a time" to
see your reply promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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