• 0

[C#] Context Menu Strip with Windows Vista look and feel


Question

Hi,

I've searched and searched google but can't find anything... I'm currently using 2 context menu strips in my application, one for the notification icon and another for the contextual menu of a textbox. I want them to have the look and feel of menus in Vista with the possibility to use icons. However, if the application is used on XP, I want the menus to have the look and feel of XP, also using the icons.

Can anyone help me out?

Recommended Posts

  • 0

You'd probably have to create your own Renderer for the ContextMenuStrip.

Have a look at this:

http://www.chaliy.com/TipsAndTricks/Vs2005LikeRendering/

and

http://www.codeproject.com/cs/menu/Office2007Renderer.asp

Edit, and this:

http://www.chaliy.com/Sources/RebarRenderer/Default.aspx

Edited by Winston
  • 0
So you have no clue right? Maybe this is only possible on VS2008 and with .NET 3.0 or maybe not? I'm not really sure as I don't have it, but it must be a way...

I could probably figure it out. Time is my only issue. I'd rather spend time with the ladies than coding. LOL

I'll see what I can come up with. I sincerely doubt it's only doable in 2008/3/3.5.

  • 0

Don't you just set the RenderMode to System?

contextMenuStrip1.RenderMode = ToolStripRenderMode.System;

EDIT: never mind, I see that doesn't do it either.

Edited by virtorio
  • 0
Don't you just set the RenderMode to System?

contextMenuStrip1.RenderMode = ToolStripRenderMode.System;

EDIT: never mind, I see that doesn't do it either.

The current render modes on VS don't do the trick. I'm using ManageRenderMode which looks like the image below, Professional (I think) also makes it look like the image:

ScalablePictureBox.jpg

In my google searches I only found about one thing. In VS2005, there's only one way to make the menus have the Vista look, I have to use the ContextMenu control and not the ContextMenuStrip. ContexMenu control is hidden, you have to add it to the toolbox. Although, there are no way to add icons to ContextMenu items, only owner-drawing, but that will loose the Vista look...

  • 0
I guess I could be wrong about it not being tied to 3.0/3.5... There has to be a way to do it natively. It's just going to take some digging. I just grabbed the latest SDK, so I'll take a look at it when I can.

Thanks, whenever you have an answer, reply back :)

  • 0

You can fully modify menustrips look and feel by using ToolStripRenderer. Just create a new class like this:

public class VistaToolstripRenderer : System.Design.ToolstripRenderer

... or something like that.

Take a look at following article in codeproject. It shows how to create a style which follows Office 2007 guidelines. If you can't accomplish the style you're trying to make, I may create it as part of my project called Cloud Toolkit.Net (https://sourceforge.net/projects/cloudtoolkitnet/). It has Office 2007 toolstriprenderer but not yet Vista or any else renderer

Codeproject article about ToolstripRenderer

Regards,

Timo Salom?ki

  • 0

The problem is that I don't want the Vista renderer. If that was the case, users running XP would have their menus themed with Vista look and that's not what I want. I want to have menus that have the visual style OS look and use icons.

  • 0

Oh right, you didn't make it so clear, I suggest this is what you do:

You can either create a class and inherit from the old ContextMenu item and do some owner drawing yourself, and refer to this class:

http://msdn2.microsoft.com/en-us/library/s....menu.item.aspx

To actually retrieve the current OS's Visual Style menu item state's.

Or you can create your own managed renderer for the ContextMenuStrip, and use the above class to handle the drawing logic as well.

[EDIT] OK, my bad, I just realised, that it's not a class supported under Vista, hmm that's weird, I think you'd really have to result into using some PInvoking to achieve it.

Edited by Winston
  • 0

Just out of curiosity, is there some reason why you don't just use one of the normal menu classes, and do all of the drawing yourself? You've probably already spent much more time looking for a boxed solution than you would have had you just done the GDI+ work yourself.

  • 0

That has been answered many times in this thread...

I can't use ContextMenu nor ContextMenuStrip because they don't use the system look depending on the OS and VisualStyle. Doing it in GDI+ wouldn't help at all. What if the user is using WindowBlinds or a hacked uxtheme.dll and use a different visual style? How is GDI+ going to help me there?

@Winston

I think I'll just forget it... I'm using ContextMenu for now, but I'm forgetting about the icons... Oh well, what you gonna do...

  • 0
I can't use ContextMenu nor ContextMenuStrip because they don't use the system look depending on the OS and VisualStyle. Doing it in GDI+ wouldn't help at all. What if the user is using WindowBlinds or a hacked uxtheme.dll and use a different visual style? How is GDI+ going to help me there?

Ummm... it'll help you because you can query the system (through Windows.Forms) to get the bitmaps/colours making up the interface at any particular moment, and then draw the menu dynamically using GDI+. There are a whole set of classes in .NET for exactly this type of scenario.

There's no need for attitude here. Since you've spent two weeks on this, I was JUST wondering why you hadn't already considered the path of least resistance..........

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • With Microsoft now listening to its core audience and acting upon received feedback, fans can finally expect a much better version of Windows 11 than what was available five years ago. Here is to five more years, Windows 11! I guess we all need a good laugh now and again...
    • Amazon Prime Day 2026 deal sees Samsung Odyssey 49" 240Hz QD-OLED monitor at lowest price by Sayan Sen Earlier today we covered a very good deal on JBL's BAR 800 Dolby Atmos soundbar system as the unit is available for just $600 as part of Amazon Prime Day 2026 deals. That's not all though as there are many more discounts to choose from. If you are looking for a high-end monitor, Samsung's 49 inch G9 QD-OLED gaming monitor is a solid deal too as it's currently just $855 (purchase link under the specs table down below). It is a super-ultrawide (32:9) 1440p curved gaming monitor and as such should offer a very immersive experience. The G93SC is a 49-inch QD-OLED (Quantum Dot OLED) screen and that means it should have excellent contrast as well as color reproduction. Brightness is a bit lacking though so if you are looking to set it up in a relatively bright room, you may be better off with something else. Speaking of external light and brightness, the major difference on the G93SC vs the newer G93SD is that the latter comes with Samsung's "Glare Free" technology to reduce glare while the C model packs a glossy finish. The technical specifications of the Samsung G93SC are given in the table below: Specification Value Panel Type OLED Screen Shape Curved Screen Curvature 1800R Resolution DQHD (5120 × 1440) Aspect Ratio 32:9 Brightness (Typical) 250 cd/m² Brightness (Minimum) 200 cd/m² Contrast Ratio 1,000,000:1 HDR Support VESA DisplayHDR True Black 400 HDR10+ HDR10+ Gaming Response Time 0.03 ms (GTG) Refresh Rate Up to 240 Hz Viewing Angle 178° Horizontal / 178° Vertical Color Support 1 Billion Colors Color Gamut 99% DCI-P3 (CIE1976) Adaptive Sync FreeSync Premium Pro / G-SYNC Compatible DisplayPort 1 × DisplayPort 1.4 HDMI 1 × HDMI 2.1 Micro HDMI 1 × Micro HDMI 2.1 USB Hub 3 × USB 3.0 Speakers Built-in Speaker Output 5W × 2 Channels Operating Temperature 10°C – 40°C Operating Humidity 10–80% (Non-condensing) Stand Type Height Adjustable Stand (HAS) Height Adjustment 120.0 ± 5.0 mm Tilt -2° (±2°) to 15° (±2°) Wall Mount 100 × 100 mm (VESA) Included HDMI Cable HDMI-to-Micro HDMI Cable Included DisplayPort Cable Yes Get it at the link below: Samsung 49" Odyssey G93SC Series Curved Gaming Monitor, QD-OLED: $854.99 (Sold and Shipped by Amazon US with Prime) Prime subscription can be cancelled within three business days at no cost. Good to know This Amazon deal is U.S. specific, and not available in other regions unless specified. We only use first-party seller links (at the time of article publishing); ensure that you purchase from a first-party seller link only. Check out Today's Deals on Amazon | or our recent tech deals. Become a Prime member (for Students or SNAP) via Neowin Get Prime Access - Prime for half price (for qualifying Medicaid, EBT, SNAP) Subscribe to Prime Video, Audible Plus, Music Unlimited or Kindle Unlimited via Neowin As an Amazon Associate, we earn from qualifying purchases.
    • Actually Windows 11 is the GUI from Windows 10 X slapped onto Windows 10. Hence the many performance issues and initial limitations of the UI, like all the restrictions on the task bar placement and features. You could not even right click on the Taskbar and bring up task manager when it first shipped. Windows 10X was truly a new OS from the ground up. Basically a lightweight OS that ran containers for various app types. Win32 got its own container. Performance was not good and OEM’s pushed back on it, but wanted a new OS to push Pc sales. Hence Windows 11. https://en.wikipedia.org/wiki/Windows_10X
    • Windows 10 was 6 years old when Microsoft revealed Windows 11. Does this mean Windows 12 is due next year?
    • Congratulations Windows.
  • Recent Achievements

    • Dedicated
      Scoobystu earned a badge
      Dedicated
    • First Post
      Tom Schmidt earned a badge
      First Post
    • One Month Later
      D0nn13 earned a badge
      One Month Later
    • Rookie
      +ChiefOfNeo went up a rank
      Rookie
    • One Year In
      Tom Schmidt earned a badge
      One Year In
  • Popular Contributors

    1. 1
      +primortal
      458
    2. 2
      +Edouard
      177
    3. 3
      PsYcHoKiLLa
      123
    4. 4
      Michael Scrip
      81
    5. 5
      Xenon
      76
  • Tell a friend

    Love Neowin? Tell a friend!