• 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

    • There is a default resolution setting in Settings > Display that can be changed with a click. You can also change the settings on a per-game basis. No CLI needed. Also, Steam has countless games that are not "[perpetual] alpha/beta games", so no need for the straw man. Plus you can use other stores as well. And console games (e.g. PS5) cost a fortune, which itself more than negates the price subsidy on the system, unless you plan on exclusively playing 1 or 2 games. It's true that you shouldn't buy a system that doesn't support the game(s) you want to play, but I think that's kinda obvious, and applies to every console as well as PC. I don't game in the living room and have no need of a Steam Machine, but there is a clear market segment that would find it useful.
    • RSS Guard 5.2.0 by Razvan Serea RSS Guard is a simple (yet powerful) feed reader. It is able to fetch the most known feed formats, including RSS/RDF and ATOM. It's free, it's open-source. RSS Guard currently supports Czech, Dutch, English, French, German, Italian. RSS Guard will never depend on other services - this includes online news aggregators like Feedly, The Old Reader and others. RSS Guard is developed on top of the Qt library and it supports these operating systems: Windows GNU/Linux OS/2 (eComStation) Mac OS X xBSD (possibly) Android (possibly) other platforms supported by Qt The core features of RSS Guard are: support for online feed synchronization via plugins, Tiny Tiny RSS (from RSS Guard 3.0.0). multiplatform, support for all feed formats, simplicity, import/export of feeds to/from OPML 2.0, downloader with own tab and support for up to 6 parallel downloads, message filter with regular expressions, feed metadata fetching including icons, simple Adblock functionality, customized popup notifications, Google-based auto-completion for internal web browser location bar, ability to cleanup internal message database with various options, enhanced feed auto-updating with separate time intervals, multiple data backend support, SQLite (in-memory DBs too), MySQL. is able to specify target database by its name (MySQL backend), “portable” mode support with clever auto-detection, feed categorization, drap-n-drop for feed list, automatic checking for updates, ability to discover existing feeds on websites, full support of podcasts (both RSS & ATOM), ability to backup/restore database or settings, fully-featured recycle bin, printing of messages and any web pages, can be fully controlled via keyboard, feed authentication (Digest-MD5, BASIC, NTLM-2), handles tons of messages & feeds, sweet look & feel, fully adjustable toolbars (changeable buttons and style), ability to check for updates on all platforms + self-updating on Windows, hideable main menu, toolbars and list headers, KFeanza-based default icon theme + ability to create your own icon themes, fully skinnable user interface + ability to create your own skins, “newspaper” view, plenty of skins, support for "feed://" URI scheme, ability to hide list of feeds/categories, open-source development model based on GNU GPL license, version 3, tabbed interface, integrated web browser with adjustable behavior + external browser support, internal web browser mouse gestures support, desktop integration via tray icon, localizations to some languages, Qt library is the only dependency, open-source development model and friendly author waiting for your feedback, no ads, no hidden costs. RSS Guard 5.2.0 changelog: Added: Feed auto-fetch can now also be delayed while Feral GameMode is active on Linux and startup auto-fetch is skipped when GameMode is already active. (#2265) WebEngine builds can now use RSS Guard generated proxy auto-config (PAC) rules so article/web browsing follows per-account and per-feed proxy settings more closely. (#2273) Generated PAC rules now also cover related subdomains and use Public Suffix List data, so feeds such as feeds.bbc.co.uk can also proxy resources from images.bbc.co.uk. (#2273) Standard feeds can now define extra proxy domains, useful when article images, stylesheets or other page resources are loaded from a CDN or another domain that should use the same feed proxy. (#2273) RSS Guard now asks for proxy credentials when a WebEngine page needs proxy authentication and can fill credentials from the current feed proxy when available. (#2273) Network settings again include an option to ignore all cookies, which clears stored cookies and prevents new cookies from being accepted. Standard RSS/ATOM feeds can now individually ignore cookies while downloading feed data. Stored cookies can now be deleted from the Tools menu. Custom skin colors can now override the feed list article count color separately from feed titles, including a separate highlighted color. (#2275) Settings dialog can now search across available settings and highlight matching controls. (#1754) Standard RSS/ATOM feeds can now optionally be reported as broken when they are valid but contain no articles. (#2039) Standard RSS/ATOM feeds can now override the application-wide feed connection timeout per feed. (#1023) Tray icon can now use a custom background color and unread-count text color, with an option to reuse the generated icon as the application icon. (#1973) Support for more benevolent parsing of Gemlog entries (#2295). Article list can now show when an article was received by RSS Guard. (#947) Feed deep discovery now actually scrapes all links found in the website and checks if they are feeds or not. This greatly enhances usability of the deep discovery mode and discovers many more feeds than before. (#2306) Search boxes now show a small dot when the feed or article list is hiding some items because of active filtering. (#873) Articles now have a shortcut-assignable action to open the homepage of the feed they belong to. (#2060) Fixed: Parallel feed updates no longer crash when multiple update results are processed at the same time. (64cf521) Links in WebEngine articles opened from feeds such as Kill the Newsletter now open correctly instead of being swallowed by the embedded page. (#2272) Relative article URLs resolution was kinda broken. (#2282) Clicking article URL did not work when the URL had "fragment" set. (#2293) The default proxy setting now uses Qt/system default proxy behavior instead of forcing no proxy. (e0263ad) WebEngine article loading now keeps the current feed context, so feed-specific proxy credentials remain available while the article page loads. (fdd0f00) Download: RSS Guard 5.2.0 (64-bit) | Portable | ~ 130.0 MB (Open Source) Link: RSS Guard Home Page | Other Operating Systems | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • This is gonna separate the creeps from the rest of the crowd.
    • "Claude, is our CEO a compete and utter fool by wasting money on AI in this already worthless Teams chat?"
  • Recent Achievements

    • Rookie
      DaviKar went up a rank
      Rookie
    • Dedicated
      HidekoYamamoto94 earned a badge
      Dedicated
    • One Month Later
      timbobit earned a badge
      One Month Later
    • One Month Later
      nates earned a badge
      One Month Later
    • Week One Done
      Almohandis earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      462
    2. 2
      +Edouard
      161
    3. 3
      PsYcHoKiLLa
      110
    4. 4
      Michael Scrip
      83
    5. 5
      Steven P.
      69
  • Tell a friend

    Love Neowin? Tell a friend!