• 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

    • AB Download Manager 1.9.2 by Razvan Serea AB Download Manager is an open-source, feature-rich download manager designed to accelerate downloads, organize files efficiently, and provide seamless control over downloads. With support for multiple connections, resume capability, and an intuitive interface, it enhances the downloading experience for users seeking speed and reliability. The software integrates with various browsers, enabling quick link grabbing and batch downloading. It supports HTTP, HTTPS, and FTP protocols, ensuring broad compatibility with different file sources. Users can schedule downloads, set speed limits, and categorize files automatically for better organization. AB Download Manager is lightweight yet powerful, making it a great alternative to proprietary download managers. Its open-source nature allows developers to contribute, customize, and improve the software as needed. Whether you're downloading large files, managing multiple downloads at once, or seeking an ad-free experience, this tool offers a practical and efficient solution. Key features of AB Download Manager: Multi-Connection Support – Accelerates downloads by splitting files into multiple segments. Resume Capability – Allows paused or interrupted downloads to be resumed without starting over. Batch Downloading – Supports downloading multiple files at once for improved efficiency. Browser Integration – Captures download links directly from browsers for seamless operation. HTTP, HTTPS, and FTP Support – Ensures compatibility with a wide range of file sources. Download Scheduling – Enables users to automate downloads at specific times. Speed Limiting – Lets users control bandwidth usage for optimized performance. File Categorization – Automatically organizes downloaded files into designated folders. User-Friendly Interface – Simple and intuitive design for easy navigation. Cross-Platform Compatibility – Works on multiple operating systems. Ad-Free Experience – No intrusive ads or tracking for a clean user experience. AB Download Manager 1.9.2 changelog: Added New Twilight theme (#1292) Optional download completion notifications on Android (#1290) Fixed Fixed a crash on some older CPUs on Windows Fixed oversized system tray icon on macOS Improved Updated translations Prevented Android devices from sleeping while downloads are active (#1291) Various UI and UX improvements Download: AB Download Manager 1.9.2 | Portable | ~80.0 MB (Open Source) Download: ARM64 | Portable ARM64 | Android Links: AB Download Manager Website | Github Page | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • I am not surprised because life is the product of a lot of biochemical and physical processes that releases various energies as a by-product. The only thing new here is the detection of these photon emissions. The researches noted this "glow" is not a metaphysical one. They don't even immediately end when one is dead. Things like fires, light bulbs, and on a bigger scale stars release a lot more "light" and they are hardly alive.
    • Did you not understand the concern of the article and/or what on-prem means?
    • If there rumours are true zen 7 will be am5 too
    • If Gemini is so great...who am I kidding! Whatever it takes to REMOVE IT, that is what I do.
  • Recent Achievements

    • Conversation Starter
      sumytbe earned a badge
      Conversation Starter
    • One Year In
      B4dM1k3 earned a badge
      One Year In
    • One Year In
      DarkWun earned a badge
      One Year In
    • Dedicated
      Almohandis earned a badge
      Dedicated
    • Dedicated
      JuvenileDelinquent earned a badge
      Dedicated
  • Popular Contributors

    1. 1
      +primortal
      515
    2. 2
      +Edouard
      186
    3. 3
      PsYcHoKiLLa
      87
    4. 4
      Michael Scrip
      79
    5. 5
      Steven P.
      73
  • Tell a friend

    Love Neowin? Tell a friend!