Dynamic Menu Issues

I’m updating a WindowMenu class that I’ve had for years and I’m experiencing some issues. In a nutshell it’s a Window subclass that in the open event adds it self to a window manager (just a module). The add is pretty simple:

Protected Sub Add(pWindow as Window) dim item as WindowMenuItem item = New WindowMenuItem(pWindow) End Sub

The WindowMenuItem (a MenuItem) constructor is:

Sub Constructor(pWindow as Window) mWindow = pWindow me.Text = mWindow.Title WindowMenu.Append me End Sub

This code has worked for years in Carbon and Windows. But in testing this today it does not work in Cocoa nor in Ubuntu 64 bit. Am I missing something that’s changed recently with dynamic menu’s?

You need to be a bit more specific then “doesn’t work”. Do you get an error message? What does the debugger tell you?

No error message. No exceptions. The menu items don’t show.

As I said, it works as expected in Carbon and Windows. Does not in Cocoa and Linux.

Never mind. Stupid programmer tricks.

The reason why it works in carbon and windows is that it was looking at the Window.MacWindowPtr and Window.WinHWND which, of course, does not work in Cocoa or Linux.