• 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
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..........

Hey dannysmurf,

Are you referring to the VisualStyles namespace? For some weird reason a lot of the visual style static classes, which represents bitmap state representations of common controls do not work under vista, for example, the Menu class isn't supported and as a result you can't query the OS for it, unless you go through other means of finding where the actualy menu items come from?

Winston

  • 0
Hey dannysmurf,

Are you referring to the VisualStyles namespace? For some weird reason a lot of the visual style static classes, which represents bitmap state representations of common controls do not work under vista, for example, the Menu class isn't supported and as a result you can't query the OS for it, unless you go through other means of finding where the actualy menu items come from?

Winston

Off the top of my head, I don't recall which namespace/classes I am referring to, but VisualStyles sounds right. It has been a while since I used them (and then, only on XP), so you may be quite right about the whole shebang not working under Vista; I honestly don't know.

  • 0

you need to override the paint event of the menu & use the menu background color

// fill selection rectangle

e.Graphics.FillRectangle(new SolidBrush(Globals.SelectionColor), e.Bounds);

// Draw borders

e.Graphics.DrawRectangle(new Pen(Globals.MenuDarkColor), e.Bounds.X, e.Bounds.Y, e.Bounds.Width - 1, e.Bounds.Height - 1);

Fill color should be "Gainsboro" or something related to exact vista color..

And on move hover you need to draw a rectange horizontal gradient starting from transparent to light blue or something related to that..

I will do the code & paste the code it either tommorrow or this weekend...because i will be travelling on other days for official meetings :-(

  • 0

I don't mean to resurrect such an old topic, but I bookmarked this page a while back so I could post when I had finished my Vista Menu component:

post-44539-1210957303.png

It's open source, written in C# and works with every .NET 2.0+ language. I've written a short article (Vista Menu with Icons in C#) introducing it which includes the download link.

I hope you find it useful.

  • 0

This is cool, thanks for all your effort on this.

However, a couple of questions because I don't have the time to test this out and I will not use it for now cause the project where I'll use is halted for the time being...

1) Will it work for any kind of menu? I mean, top menu for a form, context menu of controls that support it (like a texbox) and most important (for me), context menu of a notification icon?

2) What if some user is using a patched uxtheme.dll or WindowBlinds (either on Vista or XP or even 98), how this control handles the menu drawing?

  • 0
This is cool, thanks for all your effort on this.

However, a couple of questions because I don't have the time to test this out and I will not use it for now cause the project where I'll use is halted for the time being...

1) Will it work for any kind of menu? I mean, top menu for a form, context menu of controls that support it (like a texbox) and most important (for me), context menu of a notification icon?

It works with every control that displays MenuItems. That is, it works with the "MainMenu" control and the "ContextMenu" control. (But not the ContextMenuStrip nor MenuStrip).

One VistaMenu control per form handles all the MenuItems.

2) What if some user is using a patched uxtheme.dll or WindowBlinds (either on Vista or XP or even 98), how this control handles the menu drawing?

I separated the drawing into two groups:

1. Vista+ (i.e. Vista, 2008, any new version)

2. Pre-Vista

For Vista+ I used the correct Windows way to add icons to menus. I don't do any "owner-drawing". I just use the same method Microsoft uses to add icons. (Look in the source code for the particulars.)

For Pre-Vista I owner-draw the menus because there's no good way draw icons with Windows API. Also, menus weren't themed with 'uxtheme.dll' (or the patched version) in Windows XP, they just use solid colors. My code uses whatever system colors and system fonts are defined for the menu items.

As far WindowBlinds, I have no idea.

  • 0

We need some testing to be done then... :p

Cause this control is useless (at least for me, no offense though, great job on the control ;)) if it doesn't work everywhere. By 'everywhere' I mean WindowBlinds and such... The idea is our application to have the menus look and feel exactly the way every other menu in the system, be it on XP/Vista and/or using something like WindowBlinds or not...

Understand what I mean?

And I'm not sure about that uxtheme.dll and solid colors thing. That might be true for the default Luna visual style but there are numerous visual styles out there that have graphical menus instead of solid colors and they don't need any program to work, just a patched uxtheme.dll.

  • 0
We need some testing to be done then... :p

Cause this control is useless (at least for me, no offense though, great job on the control ;)) if it doesn't work everywhere. By 'everywhere' I mean WindowBlinds and such... The idea is our application to have the menus look and feel exactly the way every other menu in the system, be it on XP/Vista and/or using something like WindowBlinds or not...

Understand what I mean?

I do understand. Nothing works everywhere. The source is available, as are the compiled binaries. You could run the compiled binaries without touching the source and confirm whether or not WindowsBlinds works.

If it does, great! If it doesn't, add few lines of code to what I've already written and send me the changes. Or not, there's no obligation.

And I'm not sure about that uxtheme.dll and solid colors thing. That might be true for the default Luna visual style but there are numerous visual styles out there that have graphical menus instead of solid colors and they don't need any program to work, just a patched uxtheme.dll.

The uxtheme API doesn't store menu theme data for Pre-Vista versions of Windows. Everything is just solid colors (which I render correctly based on the user's color settings). See this and this.

If WindowsBlinds overrides the default Windows drawing, then I'll be glad to accept any patches to my implementation to handle WindowsBlinds. However, I won't dig through the WindowsBlinds API looking for a solution.

  • 0
If it does, great! If it doesn't, add few lines of code to what I've already written and send me the changes. Or not, there's no obligation.

If I could code something like that, I wouldn't have created this topic in the first place...

The uxtheme API doesn't store menu theme data for Pre-Vista versions of Windows. Everything is just solid colors (which I render correctly based on the user's color settings). See this and this.

That can be true but I could almost swear that I've really seen themes (specifically for uxtheme.dll patched versions) that had menus with gradients and such...

If WindowsBlinds overrides the default Windows drawing, then I'll be glad to accept any patches to my implementation to handle WindowsBlinds. However, I won't dig through the WindowsBlinds API looking for a solution.

What's the point on even releasing this control if you don't care about suggestions to improve it? We are not talking about a feature in a application where some might find useful and others don't and/or that this feature is something that makes no sense for your application (in your point of view as you made this, initially, for you; I suppose...). This is a control to have Vista menus look and feel like they belong on Vista but it's a must to have compatibility with everything related to menus. There are tons of people using WindowBlinds and someone that uses your control will want to make sure their application reaches as much users as possible.

Yeah yeah, I know the source code is available and bla bla, but that's not a reason to not improve your own product if you decided to create it and share with the public in the first place.

I'm not saying you should do it and that you are obligated to it, because your not and I really appreciate your work so far, but you could at least try and spend a few minutes to see if it works or not and if it's easy to come up with a solution or not. Instead, your are just saying you are not going to do it without even trying...

No hard feelings... :)

  • 0
I'm not saying you should do it and that you are obligated to it, because your not and I really appreciate your work so far, but you could at least try and spend a few minutes to see if it works or not and if it's easy to come up with a solution or not. Instead, your are just saying you are not going to do it without even trying...

This argument is beginning to get absurd. We're fighting about a potential bug that may or may not exist.

Before any action can be taken, you must show me a screenshot where my VistaMenu control fails. Also tell me how to reproduce the problem. If the bug is a case of me not handling all of Windows theme API correctly, then I'll fix the bug.

If it's a case of WindowsBlinds doing its own propreitary modification of Windows API (by intercepting hooks and handles and however else they do it) then I'll consider fixing the problem.

  • 0

Well, just to let you know that I tested the control on virtual XP (with VMware) and tried both uxtheme.dll and WindowBlinds and it worked flawless (as far as I could tell) for both.

Congrats on the great control.

Now you just need to make it more popular and create a better homepage for it? Have you though about posting it on CodePlex?

Just a suggestion ;)

  • 0
Now you just need to make it more popular and create a better homepage for it? Have you though about posting it on CodePlex?

If it's any consolation, I'll be redesigning my site later this summer. It'll have a nice home for all my open source controls (VistaMenu, SplitButton, etc.) instead of being spread across blog posts. But no, it won't be appearing on CodePlex.

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

    • No registered users viewing this page.
  • Posts

    • yes AND no the "original" or plain/normal Optiplex 7010 won't be getting any more new firmware updates BUT the Optiplex SFF/SFF Plus {small form factor}, Micro/Micro Plus & Tower/Tower Plus 7010 editions DO get new updates such as this new one   and here are similar guides from the Dell web site for Dell systems: https://www.dell.com/support/kbdoc/en-us/000390990/secure-boot-transition-faq https://www.dell.com/support/kbdoc/en-us/000347876/microsoft-2011-secure-boot-certificate-expiration
    • AT&T has been spying on US citizens with the NSA for decades.. they just know how to keep it more under wraps.. the evil level is still there.
    • >Improved system sounds when using Windows in dark mode. The story behind that bug would be an interesting one.
    • Edifier S3000MKII hi-fi audiophile grade bookshelf speaker is at its lowest price now by Sayan Sen Yesterday we covered a bunch of Dolby Atmos soundbar deals with several ones from Sony, as well as from JBL, Samsung, Polk Audio, and more. You can check them out in this dedicated piece. Those are not audiophile category speakers though as they are built with home theater use in mind. If you are searching for the former then Edifier has its S3000MKII at its lowest price at the moment (purchase link under the specs table down below). This is a two-way bookshelf monitor speaker designed to produce accurate sound. While it may not produce the best high-fidelity audio possible out there, it should still be significantly better than what you will get on soundbars of this price range. As such it will do justice to high-res audio played back through it. The only thing that may feel lacking is sub-bass as Edifier claims the unit can go down to 38 Hz, which should be enough for studio monitor purposes, but not for deep room-shaking rumbling bass. Where this does excel though is in its treble reproduction. With its super-tweeter, it claims to go as high as 40 kHz in the frequency spectrum, which should offer a sense of "air"yness. This is an active speaker which means it packs its own amplfication. It has a top-notch Class D amp that may be able to rival many Class AB designs too in terms of sound reproduction quality. The technical specs of the Edifier S3000MKII are given in the table below: Specification Value RMS Output Power 256W RMS (Treble: 8W × 2, Mid-Low: 120W × 2) Tweeter Driver 107mm × 107mm Planar Magnetic Tweeter Mid-Low Driver 6.5-inch (179mm) Long-Throw Aluminum Diaphragm Driver Frequency Response 38Hz – 40kHz Signal-to-Noise Ratio ≥ 85dB (A) Bluetooth Version Bluetooth 5.0 Bluetooth Codec Qualcomm® aptX™ HD Wireless Speaker Link Proprietary 5.8GHz wireless connection between speakers Supported Hi-Res Audio Hi-Res Audio Certified, up to 24-bit/192kHz Digital Processing XMOS XU216 Digital Signal Processor Audio Inputs Balanced XLR, Optical, Coaxial, USB Type-B, Line In, Bluetooth Input Sensitivity (USB) 400 ± 50mFFs Input Sensitivity (Optical) 400 ± 50mFFs Input Sensitivity (Coaxial) 400 ± 50mFFs Input Sensitivity (Bluetooth) 450 ± 50mFFs Input Sensitivity (Balanced XLR) 1000 ± 50mV Input Sensitivity (Line In) 600 ± 50mV ADC Capability Up to 24-bit/192kHz DSP Capability Up to 24-bit/192kHz DIX Capability Up to 24-bit/216kHz DAC Capability Up to 32-bit/384kHz XMOS Processing Power Up to 2,000 MIPS Edifier S3000MKII Audiophile Active (Powered) Wireless Speakers: $799.99 (Sold by Edifier US, Shipped by Amazon US) If you do not have the kind of budget to spend on the S3000MKII, you can also check out the Edifier R1280Ts which is right now on sale at just $114 (its lowest price in a very long time). 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.
  • Recent Achievements

    • One Year In
      bernmeister earned a badge
      One Year In
    • Week One Done
      Scoobystu earned a badge
      Week One Done
    • Week One Done
      tuben earned a badge
      Week One Done
    • First Post
      OffsetAbs earned a badge
      First Post
    • Reacting Well
      OffsetAbs earned a badge
      Reacting Well
  • Popular Contributors

    1. 1
      +primortal
      442
    2. 2
      +Edouard
      200
    3. 3
      PsYcHoKiLLa
      155
    4. 4
      FloatingFatMan
      71
    5. 5
      Steven P.
      67
  • Tell a friend

    Love Neowin? Tell a friend!