Problem with EnabelVisualStyles and displaying ToolBarButtons

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Richard Faust

    Problem with EnabelVisualStyles and displaying ToolBarButtons

    Hi,

    After adding the Application.Ena bleVisualStyles () 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 ;)
  • Linda Liu[MSFT]

    #2
    RE: Problem with EnabelVisualSty les and displaying ToolBarButtons

    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.Ena bleVisualStyles ();
    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(o bject sender, System.EventArg s e)
    {
    ToolBarButton b1 = new ToolBarButton() ;
    b1.ImageIndex = 1;
    this.toolBar2.I mageList = this.imageList2 ;
    this.toolBar2.B uttons.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:
    msdnmg@microsof t.com.

    =============== =============== =============== =====
    Get notification to my posts through email? Please refer to
    Gain technical skills through documentation and training, earn certifications and connect with the community

    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.


    Comment

    • Richard Faust

      #3
      Re: Problem with EnabelVisualSty les and displaying ToolBarButtons

      Linda Liu[MSFT] schrieb:
      1. Create a new Windows Application project
      2. In the static Main method, add this line of code:
      Application.Ena bleVisualStyles ();
      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(o bject sender, System.EventArg s e)
      {
      ToolBarButton b1 = new ToolBarButton() ;
      b1.ImageIndex = 1;
      this.toolBar2.I mageList = this.imageList2 ;
      this.toolBar2.B uttons.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 EnableVisualSty les() 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!






      Comment

      • Peter Duniho

        #4
        Re: Problem with EnabelVisualSty les and displaying ToolBarButtons

        On Wed, 07 May 2008 07:28:47 -0700, Richard Faust
        <softproject@co mmunity.nospamw rote:
        The problem occured only when adding the EnableVisualSty les() 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.Ena bleVisualStyles (). 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. :)

        Comment

        • Richard Faust

          #5
          Re: Problem with EnabelVisualSty les and displaying ToolBarButtons

          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.Ena bleVisualStyles (). 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

          Comment

          • Linda Liu[MSFT]

            #6
            Re: Problem with EnabelVisualSty les and displaying ToolBarButtons

            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:
            msdnmg@microsof t.com.

            This posting is provided "AS IS" with no warranties, and confers no rights.


            Comment

            Working...