Hi all,
is this the standard way of calling windows from a menu or could I do this better?
I have a Toolbar where some of the ToolButtons have a menu to select databases.
These menus will call a custom window winProtease which displays the selected database.
I have a custom menu item class menuItem_MW with two properties:
- SourceDB As REALSQLDatabase
- TargetWindow As Window
When the menu gets created at startup references to the respective databases are stored in SourceDB
When a menuItem_MW is selected then if the TargetWindow is Nil then it will create it, otherwise it will show it.
In the Toolbar’s DropDownMenuAction I have
[code] if MenuItem_MW( hitItem ).TargetWindow = Nil then
dim w as new winProtease( MenuItem_MW( hitItem ), MenuItem_MW( hitItem ).SourceDB )
w.Title = hitItem.Text
MenuItem_MW( hitItem ).TargetWindow = w
else
MenuItem_MW( hitItem ).TargetWindow.Show
end if[/code]
winProtease has to be able to tell the menu when it closes so that it can set the menu’s TargetWindow back to Nil.
So it has a property CallingMenu As MenuItem_MW (as well as db as REALSQLdatabase) and a constructor
[code]Sub Constructor(m as MenuItem_MW, SourceDB as REALSQLdatabase )
CallingMenu = m
SourceDB = db
// Calling the overridden superclass constructor.
Super.Constructor
End Sub[/code]
and in it’s Close event I reset the menu with
CallingMenu.TargetWindow = Nil
Seems to work fine, but is this the way you are supposed to do it?
Thanks
Markus