Commander button in VS2005
Commander button in VS2005
I'm updating an application from VS 2003 to 2005, and I have code where I add some buttons to a commander. The buttons are there, and work, but only part of the icons is appearing. It's as if I have a very thin button. Any idea why this is happening?
This is an example of how a button is created
System::Windows::Forms::ToolBarButton ^newButton = gcnew System::Windows::Forms::ToolBarButton();
newButton->ToolTipText = "Add/Edit the plot info";
commander1->ImageList->Images->Add(form1ButtonList->Images[0]);
newButton->ImageIndex = commander1->ImageList->Images->Count -1;
newButtons[13] = newButton;
This is an example of how a button is created
System::Windows::Forms::ToolBarButton ^newButton = gcnew System::Windows::Forms::ToolBarButton();
newButton->ToolTipText = "Add/Edit the plot info";
commander1->ImageList->Images->Add(form1ButtonList->Images[0]);
newButton->ImageIndex = commander1->ImageList->Images->Count -1;
newButtons[13] = newButton;
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi sring,
The commander is based on a System.Windows.Forms.ToolBar. Can you successfully add buttons to an instance of this class?
The commander is based on a System.Windows.Forms.ToolBar. Can you successfully add buttons to an instance of this class?
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Yes, the buttons are there, just partly hidden, it's like there is something in front of them. I have been through all of the components on the form and there doesn't seem to be anything that could account for it. The first extra button, you can see the entire left edge of the image as well as its top. The other buttons, just the top. It's as if there was a rectangle laid over most of the buttons. If you want, I can send you a jpg so that you can see what I mean.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Hello,
The cause is most likely the Label used to display Commander information (eg. Rotation and Elevation). The Label is private, we'll improve access to it for an upcoming release.
For the moment you could hide it:
eg. (There's only one Label on the Commander)
Regards,
Marc Meumann
The cause is most likely the Label used to display Commander information (eg. Rotation and Elevation). The Label is private, we'll improve access to it for an upcoming release.
For the moment you could hide it:
eg. (There's only one Label on the Commander)
Code: Select all
foreach (object o in commander1.Controls)
{ if (o is Label)
((Label)o).Visible=false;
}
Marc Meumann
Steema Support
Hello,
If I run a test using one of the images already in the list (ie. the '3D' image) to add 5 buttons all the images come out ok. You might like to confirm that:
eg.
Using a new ImageList as per your example, it checks out in the following way:
Please note that the Commander Image colours are 25x25px, Depth8Bit. In the ImageList I used the colours were 32Bit and colour 'downsizing' takes place. .. I wouldn't think that would have an effect on your image's appearance as it would have moved when you interchanged the icons, but worth bearing in mind. See if a loop similar to the one above gives the same results.
Regards,
Marc Meumann
If I run a test using one of the images already in the list (ie. the '3D' image) to add 5 buttons all the images come out ok. You might like to confirm that:
eg.
Code: Select all
for (int i = 0; i < 5; i++)
{
System.Windows.Forms.ToolBarButton newButton = new System.Windows.Forms.ToolBarButton();
newButton.ToolTipText = "My text";
newButton.ImageIndex = commander1.ImageList.Images.Count - 5;
((ToolBar)commander1).Buttons.Add(newButton);
}
Code: Select all
for (int i = 0; i < 5; i++)
{
System.Windows.Forms.ToolBarButton newButton = new System.Windows.Forms.ToolBarButton();
commander1.ImageList.Images.Add(myImageList.Images[i]);
newButton.ToolTipText = "my text";
newButton.ImageIndex = commander1.ImageList.Images.Count - 1;
((ToolBar)commander1).Buttons.Add(newButton);
}
Regards,
Marc Meumann
Steema Support
This has something to do with setting the ImageIndex.
If, in the second loop, I keep the index at the first button I add, they all look good. If I let the index increment, even if I just do it manually and don't make it depend on the count, and even if I'm adding the same icon 5 times, the third one comes out black.
If, in the second loop, I keep the index at the first button I add, they all look good. If I let the index increment, even if I just do it manually and don't make it depend on the count, and even if I'm adding the same icon 5 times, the third one comes out black.
Hello,
Interesting. That's different to the behaviour in tests here. I wonder if it has anything to do with the programming language.
Is that a useable workaround if you assign a different image to the 'fixed' index? If there's anythiing further we can try please let us know.
Regards,
Marc Meumann
Interesting. That's different to the behaviour in tests here. I wonder if it has anything to do with the programming language.
Is that a useable workaround if you assign a different image to the 'fixed' index? If there's anythiing further we can try please let us know.
Regards,
Marc Meumann
Steema Support