empty PopupMenu opens a huge empty box

When a PopupMenu has no content, it shouldn’t display anything to the user when it’s clicked. That’s how it behaves on Mac, and I’m pretty sure that’s how it used to behave on Windows. At some point this changed. Now when an empty PopupMenu is clicked on Windows, a huge empty white box drops down. This is absurd, looks like I’ve made a mistake, but it’s not my mistake, something changed under the hood. How do I stop this from happening please?

Maybe check if it is empty and use:

Me.Enabled = False

Yes, it looks weird on Windows.

I thought maybe there is some switch on Windows I’m missing. I can subclass and try workarounds like disabling, but why should I have to do that? To me this seems like a UI error in Xojo.

Its a bug with the framework, see here <https://xojo.com/issue/49534>

You can “fix” it by putting the following code in your popupmenu.open event:

Declare Function SetWindowPos Lib "User32.dll" (hWnd As Integer, hWndInsertAfter As Integer, X As Int32, Y As Int32, cx As Int32, cy As Int32, uFlags As UInt32) As Int32 Call SetWindowPos(Me.Handle, 0, 0, 0, Me.Width, Me.Height + 50, 6) ' 6 = SWP_NOMOVE + SWP_NOZORDER

Change the 50 to whatever size you want. When you use popupmenu.add (or any other method of altering the control list) on the control then the height will be changed to that height overwriting this change.

For reference, its taken from the C#.Net source here:

https://referencesource.microsoft.com/#System.Windows.Forms/winforms/Managed/System/WinForms/ComboBox.cs,378eeab68e45c735,references

The same with empty combobox (no surprise).

Good input, but it doesn’t help on Linux where the same thing can occur. This is something that Xojo needs to fix.