• 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

    • Age of Empires Mobile comes to PC, here's how to carry over progress from your phone by Ivan Jenic Image: YouTube/Microsoft Microsoft just released Age of Empires Mobile for PC. The game, officially called Age of Empires Mobile: PC Edition, is available for free on Steam and Microsoft Store, almost two years after its initial release for handheld devices. Age of Empires is one of those franchises that entire generations grew up with. The original came out in 1997, and immediately got people hooked to building civilizations and crushing their enemies on the battlefield. However, the franchise today is a far cry from its roots, as Age of Empires Mobile is, well, a game optimized for handheld devices, and not a classic RTS title we’ve all loved for years. And, of course, it includes in-game purchases. The PC version is still a mobile game at its core, but it’s been optimized for desktop play. There’s mouse control, full keyboard compatibility, and a refined UI. Microsoft also refreshed the visuals with some 4k textures, so the game should look better on larger screens. The game supports Crossplay, so you can switch between your phone, tablet, and PC without losing anything. But linked progress doesn’t come out of the box, as you have to enable it first. Here’s how to link your progress: On your mobile device, open Age of Empires Mobile. Go to Settings (Gear icon) > Account. Select Bind Account and choose a sign-in option. Once you enable account binding, sign in on PC using the same method, and your progress will be accessible across all your devices. Xbox Game Pass subscribers also get a bonus reward pack on PC, which includes: 1 Monthly Pass Token 1 Custom Resource Chest 10 Universal 60-Minute Speed-Ups 1,000 Empire Coins Exclusive Player Portrait Frame You can find more info about Age of Empires Mobile: PC Edition, as well as download links, on the Age of Empires official website.
    • Apple Watch Series 11 GPS just crashed to 30% off in this fast-moving Prime Day deal by Karthik Mudaliar The Apple Watch Series 11 is available for $279, down from its $399 list price, saving buyers $120, or 30%. Amazon labels the offer as selling fast, so the current price may not remain available for long. This GPS model features a 42mm aluminum case, an Always-On Retina LTPO3 OLED display capable of reaching up to 2,000 nits, and an Ion-X glass surface with improved scratch resistance. Apple rates Series 11 for up to 24 hours of normal use or up to 38 hours in Low Power Mode, with fast charging providing up to eight hours of use from a 15-minute charge. Health and fitness tools include sleep scoring, temperature sensing, ECG support, heart-rate alerts, workout tracking, sleep apnea notifications, and hypertension notifications, where available. The watch also carries IP6X dust resistance and 50-meter water resistance. This configuration is best suited to iPhone owners who want comprehensive health tracking, notifications, contactless payments, and workout data without stepping up to a larger or cellular-equipped model. The smaller case should also appeal to buyers who prefer a lighter watch, while the S/M band fits wrists measuring 130mm to 180mm. With the current generation now significantly below its usual retail price, this is a strong time to replace an aging Apple Watch or buy a first model without compromising on Apple’s newest health and display features. Grab the discounted Apple Watch Series 11 (sold and shipped by Amazon) 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.
    • The laptop in the bedroom is an Acer with i7-10510U CPU. Acer's website states they will not be upgrading it so I had little choice other than disable secure boot. I know next to nothing on these matters so hopefully it will be fine.
    • GitHub removes manual model selection from Copilot free and student plans by Karthik Mudaliar GitHub is removing the ability to manually select an AI model from its Copilot Free and Student plans, making its automatic routing system the default and only way to choose a model. This means users on these tiers will no longer be able to deliberately select a particular OpenAI, Anthropic, Google, or Microsoft model for a task. In its announcement, GitHub said Copilot Auto will dynamically choose what it considers the best model for each request. Free and Student accounts will retain access to models from multiple families, although the available selection will continue to depend on the restrictions attached to each plan. GitHub did not identify a fixed pool of models that Auto will always use, and its documentation warns that model availability can change over time. GitHub describes Auto as more than a random fallback system. On supported surfaces, its task-optimization technology evaluates the complexity of a request alongside real-time information about model health and availability. Straightforward prompts can be routed to faster and less expensive models, while more demanding coding tasks may be sent to higher-cost reasoning models. The company says this approach should reduce rate limiting, latency, and failed requests. Auto generally selects one model along natural prompt-caching boundaries rather than repeatedly switching models during a session, as GitHub found that mid-session changes increased costs without producing sufficient improvements in output quality. Users can still check which model generated a response. In Copilot Chat, the information appears when hovering over an answer, while Copilot CLI and the Copilot cloud agent display the selected model alongside their output. Auto is available in Copilot Chat, Copilot CLI, and the cloud agent, with the exact implementation and release status varying between supported development environments. The latest restriction follows several months of adjustments to Copilot’s individual plans. GitHub temporarily halted new Pro, Pro+, and Student subscriptions in April as it sought to manage demand and service reliability. It later introduced token-based billing and began gradually reopening individual-plan registrations on June 17. Alongside the picker change, GitHub is retiring the “Preview” label from Microsoft-developed models. It argues that the label is no longer necessary because Auto handles model routing and models are continuously updated behind the scenes.
  • Recent Achievements

    • One Year In
      Philsl earned a badge
      One Year In
    • 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
  • Popular Contributors

    1. 1
      +primortal
      460
    2. 2
      +Edouard
      177
    3. 3
      PsYcHoKiLLa
      124
    4. 4
      Michael Scrip
      79
    5. 5
      Xenon
      76
  • Tell a friend

    Love Neowin? Tell a friend!