Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - CommandBarButton Width
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CommandBarButton Width

 Post Reply Post Reply
Author
Message
apuhjee View Drop Down
Senior Member
Senior Member
Avatar

Joined: 02 September 2005
Location: United States
Status: Offline
Points: 130
Post Options Post Options   Thanks (0) Thanks(0)   Quote apuhjee Quote  Post ReplyReply Direct Link To This Post Topic: CommandBarButton Width
    Posted: 26 June 2007 at 5:25pm
At what point is the Width of a RibbonBar button known?  I'm trying to add three "state" buttons and set them all to be the same size as the widest... but the width = 0 immediately after they have been added to a group.
 
Thanks ~ jp
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 27 June 2007 at 12:48am

Hi,

Show code you tried.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
apuhjee View Drop Down
Senior Member
Senior Member
Avatar

Joined: 02 September 2005
Location: United States
Status: Offline
Points: 130
Post Options Post Options   Thanks (0) Thanks(0)   Quote apuhjee Quote  Post ReplyReply Direct Link To This Post Posted: 27 June 2007 at 2:08am
This is what it looks like by default:
 
 
 
This is what I'm going for:
 
 
 
Notice the watch value:
 
 
 
And here is the code I'm using.   Note: it looks ok if I uncomment the explicit width values of 60... but I'd rather not assume that the font metrics will always be the same as they are on my dev machine
 

private static void ConfigureViewTag()

{

    RibbonTab tabView = AddTab(ID.ID_TAB_VIEW, "View");

    RibbonGroup groupPanes = AddGroup(tabView.Id, ID.ID_GROUP_PANES, "Panes", false, null);

   

    viewObjectExplorerPane = AddControl(groupPanes.Id, "VIEW_OBJECT_EXPLORER_PANE", XTPControlType.xtpControlButton, "Object Explorer", "Show/Hide the Object Explorer Pane", "ToggleObjectExplorerPaneAction");

    CommandBars.Icons.LoadIcon(Path.Combine(ResourceManager.ResourcePath, "object_explorer.ico"), viewObjectExplorerPane.Id, XtremeCommandBars.XTPImageState.xtpImageNormal);

 

    viewPropertiesPane = AddControl(groupPanes.Id, "VIEW_PROPERTIES_PANE", XTPControlType.xtpControlButton, "Properties", "Show/Hide the Properties Pane", "TogglePropertiesPaneAction");

    CommandBars.Icons.LoadIcon(Path.Combine(ResourceManager.ResourcePath, "properties.ico"), viewPropertiesPane.Id, XtremeCommandBars.XTPImageState.xtpImageNormal);

 

    viewCalendarPane = AddControl(groupPanes.Id, "VIEW_CALENDAR_PANE", XTPControlType.xtpControlButton, "Calendar", "Show/Hide the Calendar Pane", "ToggleCalendarPaneAction");

    CommandBars.Icons.LoadIcon(Path.Combine(ResourceManager.ResourcePath, "calendar.ico"), viewCalendarPane.Id, XtremeCommandBars.XTPImageState.xtpImageNormal);

 

    SetEqualButtonWidth(groupPanes);

 

    //viewObjectExplorerPane.Width = 60;

    //viewPropertiesPane.Width = 60;

    //viewCalendarPane.Width = 60;

}

 

public static void SetEqualButtonWidth(RibbonGroup group)

{

    int maxWidth = 0;

    foreach (CommandBarControl control in group)

    {

        if (control.Width > maxWidth)

            maxWidth = control.Width;

    }

 

    foreach (CommandBarControl control in group)

    {

        control.Width = maxWidth;

    }

}

 

public static CommandBarControl AddControl(int groupId, string resourceName, XTPControlType controlType, string controlCaption, string controlDescription, string actionMethod)

{

    RibbonGroup group = RibbonBar.FindGroup(groupId);

    int resourceId = ResourceManager.AddResource(resourceName);

    CommandBarControl control = group.Add(controlType, resourceId, controlCaption, false, false);

    control.Action.Tag = actionMethod;

    CommandBars.Actions.Add(resourceId, controlCaption, controlCaption, controlDescription, group.Caption);

 

    return control;

}

 

 
Back to Top
apuhjee View Drop Down
Senior Member
Senior Member
Avatar

Joined: 02 September 2005
Location: United States
Status: Offline
Points: 130
Post Options Post Options   Thanks (0) Thanks(0)   Quote apuhjee Quote  Post ReplyReply Direct Link To This Post Posted: 27 June 2007 at 2:21am
While we're on the topic (sort of...), it would be extremely awesome if you guys would make a true state button rather than require the use of the Checked property.
 
It may not have been a problem in the past, but with the animation in the Ribbon Bar, the short time between the user click and setting the Button.Checked property looks a little strange.
 
But I'm a perfectionist.  
 
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 27 June 2007 at 4:05am
Hi,
Before it become visible Width will be 0. you can set Width parameter to some predefined value.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
apuhjee View Drop Down
Senior Member
Senior Member
Avatar

Joined: 02 September 2005
Location: United States
Status: Offline
Points: 130
Post Options Post Options   Thanks (0) Thanks(0)   Quote apuhjee Quote  Post ReplyReply Direct Link To This Post Posted: 27 June 2007 at 4:08pm
Very interesting. So I have to display it to the user first - then change its visual appearance.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.031 seconds.