3

I am attempting to make a button that shows a user-menu, as seen in Google Chrome:

enter image description here

There's no legacy way of doing this, so I've had a look around and I have found that every way of doing this is either outdated or does not work (probably because it's outdated!).

This is the first link I found, but however it only works with Windows Aero off, and probably not with Windows 8, 8.1, or 10, and not very well. The answer to this Stack Overflow question is also essentially the same code:

enter image description here

Aero on:

enter image description here

I have also found some questions here, but the techniques mentioned do not work. One of the answers points to this MSDN article which appears to offer some of the functionality I want, but the code however is .

Is this possible in VB.NET without any issues, and if so, how?

This is with VB.NET and Windows Forms, target operating systems are Windows 7 and newer.

Community
  • 1
  • 1
AStopher
  • 4,207
  • 11
  • 50
  • 75
  • @JasonC This is essentially the same code as in the first link I gave; it doesn't work with Windows Aero, and doesn't display properly in non-Aero mode. Updated answer to reflect this. – AStopher Mar 24 '15 at 16:42
  • Take a look at these 2 links: [Adding caption buttons to the Non-client area on Vista](http://www.thecodeking.co.uk/2007/09/adding-caption-buttons-to-non-client.html#.VRLAq47LdQQ) [.Net ActiveButtons Library](http://www.thecodeking.co.uk/2007/03/net-activebuttons-library.html#.VRLA647LdQQ) – Zohar Peled Mar 25 '15 at 14:08

1 Answers1

2

Take a look at these 2 links:

Adding caption buttons to the Non-client area on Vista

.Net ActiveButtons Library

It's been a while since I've used VB.Net, so if you don't mind I'll just add a c# code example (basically I took the example from the first link and tried it, it seems to be working fine)

private void Form1_Load(object sender, EventArgs e)
{
    IActiveMenu menu = ActiveMenu.GetInstance(this);
    ActiveButton button = new ActiveButton();
    button.BackColor = Color.LightBlue;
    button.Text = "One";
    button.Click += button_Click;
    menu.Items.Add(button);
}

private void button_Click(object sender, EventArgs e)
{
    MessageBox.Show("Button clicked");
}

Note: This button doesn't seem to support transparent background, so it doesn't look quite as good as the button in chrome.

mrid
  • 5,782
  • 5
  • 28
  • 71
Zohar Peled
  • 79,642
  • 10
  • 69
  • 121
  • the above link seems to have gone. by any chance do you have the library/sample project for reference ?? – mrid Jan 10 '18 at 10:17
  • @mrid Not really, but I did find some interesting things when searching... https://www.google.co.il/search?rlz=1C1LENP_iwIL718IL718&biw=1280&bih=958&ei=7ulVWu-GDceUUZLxoIAC&q=add+a+button+next+to+minimize+&oq=add+a+button+next+to+minimize+&gs_l=psy-ab.3..0i22i30k1.24094.33027.0.33803.23.18.2.3.3.0.160.2205.0j16.16.0....0...1c.1.64.psy-ab..2.21.2228...0j0i13k1j35i39k1j0i13i30k1j33i22i29i30k1.0.lzWfbs9vrfY – Zohar Peled Jan 10 '18 at 10:26
  • Use Wayback Machine to get link: https://web.archive.org/web/20150526051947/http://www.thecodeking.co.uk/2007/03/net-activebuttons-library.html#.VWQChXbP3rc – Mubarrat Hasan Jan 11 '23 at 12:33
  • The latest version of .Net ActiveButtons has been forked. That should help (even though it's been recently archived on GitHub as well) https://github.com/tomaszmalik/ActiveButtons.Net – vr_driver Jul 28 '23 at 08:54