473,394 Members | 1,739 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Problem with EnabelVisualStyles and displaying ToolBarButtons

Hi,

After adding the Application.EnableVisualStyles() in the Main-Method of
my application, i got some strange problems
with ToolBarButtons. When the Image of the button is set during
designtime everything's ok. But all the buttons
which load their image during runtime from an ImageList and/or are
dynamicaly created have the following problems:
In default-state the button is invisible, in down-state too, but the
border higlight of the mouseover-state works.
Image is not displayed in either state.

Thanks for any help!
Martin

PS: Sorry for my bad english, but the german community is far too small
at the moment ;)
Jun 27 '08 #1
5 1010
Hi Martin,

I performed some tests based on your description but didn't reproduce the
problem on my side.

The steps of my test are as follows:

1. Create a new Windows Application project
2. In the static Main method, add this line of code:
Application.EnableVisualStyles();
3. Drag two ToolBar controls from Toolbox onto the Form1
4. Drag two ImageLists to Form1
5. Insert some images into the two ImageLists
6. Assign imageList1 to ToolBar1
7. Insert some ToolBarButtons to the toolBar1. Set ImageIndex property for
each button, the image is immediately shown up
8. Add a Button to the Form1and in the Click event handler of this button,
add the following lines of code:

private void button1_Click(object sender, System.EventArgs e)
{
ToolBarButton b1 = new ToolBarButton();
b1.ImageIndex = 1;
this.toolBar2.ImageList = this.imageList2;
this.toolBar2.Buttons.Add(b1);
}

10. Build the project and run it. When I click the button on the
Form1, a ToolBarButton appears in the ToolBar2 with the specified image.

I performed tests in both VS.NET 2003 and VS2005 and got the same result.
The OS of my test machine is Windows Server 2003.

What version of Visual Studio are you using?
What's the OS version on your machine?
Is there any difference between your project and mine?

If the problem still not solved, could you please show us the relevant code
snippet or reproduce the problem in a simple project and send it to me? To
get my actual email address, remove 'online' from my displayed email
address.

I look forward to your reply.

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

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/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Jun 27 '08 #2
Linda Liu[MSFT] schrieb:
1. Create a new Windows Application project
2. In the static Main method, add this line of code:
Application.EnableVisualStyles();
3. Drag two ToolBar controls from Toolbox onto the Form1
4. Drag two ImageLists to Form1
5. Insert some images into the two ImageLists
6. Assign imageList1 to ToolBar1
7. Insert some ToolBarButtons to the toolBar1. Set ImageIndex property for
each button, the image is immediately shown up
8. Add a Button to the Form1and in the Click event handler of this button,
add the following lines of code:

private void button1_Click(object sender, System.EventArgs e)
{
ToolBarButton b1 = new ToolBarButton();
b1.ImageIndex = 1;
this.toolBar2.ImageList = this.imageList2;
this.toolBar2.Buttons.Add(b1);
}

10. Build the project and run it. When I click the button on the
Form1, a ToolBarButton appears in the ToolBar2 with the specified image.
Hi Linda,

The problem occured only when adding the EnableVisualStyles() to an
older project which was originaly not designed for that case i think.
Since the project is very complex in architecture and i'm not one of the
initial developers i have no clue where the problem did came from.

I just remade the ToolBar from scratch once again following your steps
and now everything works as it is supposed to be, even if i can't see
any difference in the code.

Just FYI:
Windows XP Home (wrong coice for a developer, i'll change that ;)
Visual Studio 2005, .Net Framework 2

Anyway, thank you very much for your help!


Jun 27 '08 #3
On Wed, 07 May 2008 07:28:47 -0700, Richard Faust
<so*********@community.nospamwrote:
The problem occured only when adding the EnableVisualStyles() to an
older project which was originaly not designed for that case i think.
Since the project is very complex in architecture and i'm not one of the
initial developers i have no clue where the problem did came from.

I just remade the ToolBar from scratch once again following your steps
and now everything works as it is supposed to be, even if i can't see
any difference in the code.
Without a concise-but-complete code example that reliably reproduces the
problem, it's nearly impossible to answer your question. Especially when
you yourself have confirmed that you yourself cannot reproduce the problem
with a brand new project.

That said, I'll make a wild guess: there's something about the older
project that initializes something important before the line you added
that calls Application.EnableVisualStyles(). Possibly in a DLL
initialization entry point or something like that, which would be less
obvious than something called by your application entry point.

I think that's the sort of thing you'll want to look for. Other than
that, unless you can provide a concise-but-complete code example, I'm not
hopeful that anyone would be able to answer the question.

Pete

p.s. I'm not sure why you apologized for your English...you write better
than many native speakers do. :)
Jun 27 '08 #4
p.s. I'm not sure why you apologized for your English...you write
better than many native speakers do. :)
Hi Pete,

Thanks for the compliment, guess I always underestimate myself a bit ;)
That said, I'll make a wild guess: there's something about the older
project that initializes something important before the line you added
that calls Application.EnableVisualStyles(). Possibly in a DLL
initialization entry point or something like that, which would be less
obvious than something called by your application entry point.
Well, so far I'm happy with my remade (working) ToolBar, but i'll have a
look at that. When I'm able to pinpoint something out i'll make another
post.

Thanks for the directions :)
Martin
Jun 27 '08 #5
Hi Martin,

Thank you for your reply!

For now, I will close this issue in the newsgroup. If you have new findings
to this problem later, you may reopen this post or post another thread and
we will work with you at that time.

Thank you for using our MSDN Managed Newsgroup Support Service!

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.
Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: euang | last post by:
Hi, I have been using access 2000 for two years on WINDOWS NT to display dynamic aweb page using ASP My ISP has now changed to Windows 2003, and I am having major problems displaying...
8
by: Ramesh | last post by:
hi, My C# application displaying correctly in IE, But in netscape all input controls (text box, dblist, drop down list and etc.,) disappered. Only lables are displaying. The value inside the drop...
2
by: Balamurali C | last post by:
Hi All I'm having one problem, since im debuging this last one week I'm not able to do. Problem: In my webage I have two Frames(top & bottom) in the top frame I'm displaying some...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
2
by: Fedor G via DotNetMonster.com | last post by:
Pls help me manage the data displaying on the webform aspx c# page. I used Dreamweaver to manage data displaying in the repeat table, ie simply dragged the fields to the table cells, where I need...
2
by: lottoman | last post by:
Hi all, Is it possible to define shortcuts for toolbarbuttons? Can I also get the underscore underneath the specified letter? Thanks
1
by: johnVarma | last post by:
Hi All, Iam facing a problem with bar chart using coldFusion. if there is only one <cfchartseries> tag then the seriesLabel attribute is not displaying instead of that the items of the...
0
by: paragguptaiiita | last post by:
I have one problem regarding displaying text from XML file. I have a XSL variable named $p = (0 0 0) (0.82 0 0) (1.63 -0.01 0) (2.63 -0.01 0) (3.63 -0.01 0) (4.63 -0.01 0) (5.63 -0.02 0) (6.63 -0.02...
1
by: Maanav Jackson | last post by:
Hi I am displaying a third party webpage into a variable using curl library. When i am displaying the variable in the browser using echo command as shown below. echo $pagecopy; Browser is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.