• 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

    • Same, never saw it on Android or iOS. Guess only some people got it *shrugs*
    • Anthropic pulls Fable 5 and Mythos 5 after US export control order by Pradeep Viswanathan In April this year, Anthropic launched the Claude Mythos Preview frontier model with state-of-the-art cyber and coding capabilities for a select set of companies around the world. After preparing appropriate guardrails, early this week, Anthropic launched Claude Fable 5 and Mythos 5, its most capable AI models. Claude Fable 5 is for general users and comes with strict safeguards, while Mythos 5 is designed with fewer safeguards for cybersecurity and biology use cases. Today, Anthropic abruptly suspended access to its Fable 5 and Mythos 5 AI models for all customers after receiving an export control directive from the US government. The company received the directive from the government today at 5:21 p.m. ET, and the received letter did not provide any details regarding the national security concern. Anthropic understands that the government became aware of a method to bypass, or “jailbreak,” Fable 5, which might be the reason behind the directive. The order was issued under national security authorities and requires the company to suspend all access to Fable 5 and Mythos 5 by any foreign national, whether they are inside or outside the United States. The restriction also applies to foreign national employees working at Anthropic. As a result, the company has disabled both models for all customers to ensure compliance. Access to previous Anthropic models like Opus and Sonnet is not affected by this government order. The company highlighted that it had developed strong safeguards to reduce the possibility that Fable is misused for tasks related to cybersecurity. In fact, many developers are complaining that the safeguards are going overboard. Additionally, the company worked with the US government, the UK AISI, multiple private third-party organizations, and internal teams to red-team Fable’s safeguards for thousands of hours. Finally, Anthropic noted that no testers have yet been able to find a universal jailbreak on Fable 5. As expected, Anthropic disagrees that a narrow potential jailbreak should lead to the recall of a commercial model used by hundreds of millions of people. It warned that applying this standard across the AI industry could effectively halt new frontier model deployments. Anthropic concluded by mentioning that it is working to restore access to Fable 5 and Mythos 5 as soon as possible and plans to share more details within the next 24 hours.
    • Brave Browser 1.91.172 is out.
    • Any Video Converter Free 9.2.3 by Razvan Serea Any Video Converter is an All-in-One video converting tool with an easy-to-use graphical interface, fast converting speed and excellent video quality. Any Video Converter supports all popular video formats and converts your videos to different video formats including MP4, MOV, MKV, M2TS, M4V, MPEG, AVI, WMV, ASF, OGV, WEBM, and more. It supports converting videos to customized percent (50%, 100%, 200%, and more) or resolution (480p, 720p, 1080p, 4K, and more); It supports encoding videos into x264, x265, h263p, xvid, mpeg, wmv, and more. Any Video Converter Free key features: Compatible with Windows 11/10/8.1/8/7 (32-64bit) User interface are available in 14 languages Convert all kinds of video formats including high-definition videos Extract audio from any videos and save as MP3/WMA for your mp3 player Take snapshot from any videos and build your own picture collection Support high-definition for both input and output Batch add videos from hard drive and batch convert Customize output parameters completely as you like Manage your output videos files by group or output profile Merge several video files into a single and long one Clip a video into segments Free Audio Filter: Adjust audio volume and add audio effects Crop frame size to remove black bars and retain what you want only Adjust the brightness, contrast, saturation Rotate or flip or add noise/sharpen effects Produce output video with subtitles of your own dialogue and much, much more... Any Video Converter Free 9.2.3 changelog: Fixed video download engine auto-update failures. Added custom speed control support in the speed change tool. Added support for downloading YouTube AI-generated subtitles. Added support for preserving original audio stream in the format convert tool (e.g., Dolby Atmos, DTS:X). Fixed other bugs and improved overall performance. Download: Any Video Converter Free 9.2.3 | 7.6 MB (Freeware) View: Any Video Converter Free Home Page | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
  • Recent Achievements

    • Contributor
      MarkHughes4096 went up a rank
      Contributor
    • Dedicated
      jordanspringer earned a badge
      Dedicated
    • Rookie
      Rimplesnort went up a rank
      Rookie
    • One Year In
      Markus94287 earned a badge
      One Year In
    • One Month Later
      Markus94287 earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      506
    2. 2
      +Edouard
      176
    3. 3
      PsYcHoKiLLa
      149
    4. 4
      ATLien_0
      92
    5. 5
      Steven P.
      79
  • Tell a friend

    Love Neowin? Tell a friend!