Icons in Application Menus

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

    #1

    Icons in Application Menus

    Hi,
    I have just searched MSDN and Google and can't find a tutorial about how to
    add icons to menus in a VB.NET or C#.NET Windows Forms application.
    Does anyone know how it's done or can point me at a tutorial that is easy to
    follow.

    In anticipation, thanks.

    Graham Sivill
    Martley, Near Worcetser UK.


  • James Jardine

    #2
    Re: Icons in Application Menus


    "Siv" <dotnet@remove_ me.sivill.com> wrote in message
    news:OBvrBjFSGH A.4440@TK2MSFTN GP11.phx.gbl...[color=blue]
    > Hi,
    > I have just searched MSDN and Google and can't find a tutorial about how
    > to add icons to menus in a VB.NET or C#.NET Windows Forms application.
    > Does anyone know how it's done or can point me at a tutorial that is easy
    > to follow.
    >
    > In anticipation, thanks.
    >
    > Graham Sivill
    > Martley, Near Worcetser UK.
    >[/color]

    You have to set the OwnerDraw property on the menu item. Then override the
    onPaint method I believe. here is a link that shows an example of this.
    Their menus are not that pretty but it should give you an idea of how to do
    this. The sample is in C#, Sorry that is the first I found. Should be an
    easy conversion though.



    Comment

    • Siv

      #3
      Re: Icons in Application Menus

      James,
      Thanks, all I could find was an old VB6 example that looked a bit Windows
      API for me!

      Graham Sivill
      Martley, Near Worcester, UK

      "James Jardine" <james.jardine@ geoage.com> wrote in message
      news:uXsNXsFSGH A.4752@TK2MSFTN GP10.phx.gbl...[color=blue]
      >
      > "Siv" <dotnet@remove_ me.sivill.com> wrote in message
      > news:OBvrBjFSGH A.4440@TK2MSFTN GP11.phx.gbl...[color=green]
      >> Hi,
      >> I have just searched MSDN and Google and can't find a tutorial about how
      >> to add icons to menus in a VB.NET or C#.NET Windows Forms application.
      >> Does anyone know how it's done or can point me at a tutorial that is easy
      >> to follow.
      >>
      >> In anticipation, thanks.
      >>
      >> Graham Sivill
      >> Martley, Near Worcetser UK.
      >>[/color]
      >
      > You have to set the OwnerDraw property on the menu item. Then override
      > the onPaint method I believe. here is a link that shows an example of
      > this. Their menus are not that pretty but it should give you an idea of
      > how to do this. The sample is in C#, Sorry that is the first I found.
      > Should be an easy conversion though.
      > http://www.c-sharpcorner.com/Code/20...rawMenusSK.asp
      >[/color]


      Comment

      • James Jardine

        #4
        Re: Icons in Application Menus


        "Siv" <dotnet@remove_ me.sivill.com> wrote in message
        news:%23qjEhzFS GHA.4456@TK2MSF TNGP14.phx.gbl. ..[color=blue]
        > James,
        > Thanks, all I could find was an old VB6 example that looked a bit Windows
        > API for me!
        >
        > Graham Sivill
        > Martley, Near Worcester, UK
        >
        > "James Jardine" <james.jardine@ geoage.com> wrote in message
        > news:uXsNXsFSGH A.4752@TK2MSFTN GP10.phx.gbl...[color=green]
        >>
        >> "Siv" <dotnet@remove_ me.sivill.com> wrote in message
        >> news:OBvrBjFSGH A.4440@TK2MSFTN GP11.phx.gbl...[color=darkred]
        >>> Hi,
        >>> I have just searched MSDN and Google and can't find a tutorial about how
        >>> to add icons to menus in a VB.NET or C#.NET Windows Forms application.
        >>> Does anyone know how it's done or can point me at a tutorial that is
        >>> easy to follow.
        >>>
        >>> In anticipation, thanks.
        >>>
        >>> Graham Sivill
        >>> Martley, Near Worcetser UK.
        >>>[/color]
        >>
        >> You have to set the OwnerDraw property on the menu item. Then override
        >> the onPaint method I believe. here is a link that shows an example of
        >> this. Their menus are not that pretty but it should give you an idea of
        >> how to do this. The sample is in C#, Sorry that is the first I found.
        >> Should be an easy conversion though.
        >> http://www.c-sharpcorner.com/Code/20...rawMenusSK.asp
        >>[/color]
        >
        >[/color]

        Here is another link http://www.codeproject.com/cs/menu/menuimage.asp that
        has better looking menus.. I hope this helps get you started. Good Luck

        jjardine


        Comment

        • Herfried K. Wagner [MVP]

          #5
          Re: Icons in Application Menus

          "Siv" <dotnet@remove_ me.sivill.com> schrieb:[color=blue]
          > I have just searched MSDN and Google and can't find a tutorial about how
          > to add icons to menus in a VB.NET or C#.NET Windows Forms application.
          > Does anyone know how it's done or can point me at a tutorial that is easy
          > to follow.[/color]

          Which version of the .NET Framework are you using? If you are using .NET
          Framework 2.0 (VS 2005), simply use the built-in MenuStrip control.

          --
          M S Herfried K. Wagner
          M V P <URL:http://dotnet.mvps.org/>
          V B <URL:http://classicvb.org/petition/>

          Comment

          • Siv

            #6
            Re: Icons in Application Menus

            Herfried,
            I am using VB.NET 2005 with the 2.0 Framework, could you explain how the
            menustrip works, I thought they were for creating pop-up menus?
            Siv

            "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
            news:ODsSL5HSGH A.2536@tk2msftn gp13.phx.gbl...[color=blue]
            > "Siv" <dotnet@remove_ me.sivill.com> schrieb:[color=green]
            >> I have just searched MSDN and Google and can't find a tutorial about how
            >> to add icons to menus in a VB.NET or C#.NET Windows Forms application.
            >> Does anyone know how it's done or can point me at a tutorial that is easy
            >> to follow.[/color]
            >
            > Which version of the .NET Framework are you using? If you are using .NET
            > Framework 2.0 (VS 2005), simply use the built-in MenuStrip control.
            >
            > --
            > M S Herfried K. Wagner
            > M V P <URL:http://dotnet.mvps.org/>
            > V B <URL:http://classicvb.org/petition/>[/color]


            Comment

            • Herfried K. Wagner [MVP]

              #7
              Re: Icons in Application Menus

              "Siv" <dotnet@remove_ me.sivill.com> schrieb:[color=blue]
              > I am using VB.NET 2005 with the 2.0 Framework, could you explain how the
              > menustrip works, I thought they were for creating pop-up menus?[/color]

              Simply place a menustrip control on the form :-). You can use the new menu
              control for popup menus too.

              --
              M S Herfried K. Wagner
              M V P <URL:http://dotnet.mvps.org/>
              V B <URL:http://classicvb.org/petition/>

              Comment

              • Siv

                #8
                Re: Icons in Application Menus

                Herfried,

                Once I figured out how to get it to dock to the top of the form I got it
                working. I tried using some of the bitmaps from the "Command" section of
                the VS2005 Image Library. At the moment they appear in the menu with a
                magenta background, I haven't run the app yet as I have some code that needs
                tidying up before running. I assume the magenta bit will appear
                transparent? If not how do I get the icons to appear as normal?

                As always, thanks for your help!

                Siv

                "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
                news:OV6wwaISGH A.4944@TK2MSFTN GP10.phx.gbl...[color=blue]
                > "Siv" <dotnet@remove_ me.sivill.com> schrieb:[color=green]
                >> I am using VB.NET 2005 with the 2.0 Framework, could you explain how the
                >> menustrip works, I thought they were for creating pop-up menus?[/color]
                >
                > Simply place a menustrip control on the form :-). You can use the new
                > menu control for popup menus too.
                >
                > --
                > M S Herfried K. Wagner
                > M V P <URL:http://dotnet.mvps.org/>
                > V B <URL:http://classicvb.org/petition/>[/color]


                Comment

                • Herfried K. Wagner [MVP]

                  #9
                  Re: Icons in Application Menus

                  "Siv" <dotnet@remove_ me.sivill.com> schrieb:[color=blue]
                  > I tried using some of the bitmaps from the "Command" section of the
                  > VS2005 Image Library. At the moment they appear in the menu with a magenta
                  > background, I haven't run the app yet as I have some code that needs
                  > tidying up before running. I assume the magenta bit will appear
                  > transparent? If not how do I get the icons to appear as normal?[/color]

                  Set the menu items' 'ImageTranspare ntColor' property to magenta.

                  --
                  M S Herfried K. Wagner
                  M V P <URL:http://dotnet.mvps.org/>
                  V B <URL:http://classicvb.org/petition/>

                  Comment

                  • Siv

                    #10
                    Re: Icons in Application Menus

                    Herfried,
                    Thanks, this fixes the problem.
                    Siv

                    "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
                    news:eUWYF1ISGH A.5036@TK2MSFTN GP12.phx.gbl...[color=blue]
                    > "Siv" <dotnet@remove_ me.sivill.com> schrieb:[color=green]
                    >> I tried using some of the bitmaps from the "Command" section of the
                    >> VS2005 Image Library. At the moment they appear in the menu with a
                    >> magenta background, I haven't run the app yet as I have some code that
                    >> needs tidying up before running. I assume the magenta bit will appear
                    >> transparent? If not how do I get the icons to appear as normal?[/color]
                    >
                    > Set the menu items' 'ImageTranspare ntColor' property to magenta.
                    >
                    > --
                    > M S Herfried K. Wagner
                    > M V P <URL:http://dotnet.mvps.org/>
                    > V B <URL:http://classicvb.org/petition/>[/color]


                    Comment

                    Working...