getVPIWindow will raise an exception if the window is not actually created/shown.
whenCreated postpones the call until the window is created. If is is already created it just run the code.
In a show-handler the window is created, in the constructor/
generatedInitialize the window is not yet created.
So in a show handler
whenCreated is not necessary, but in the constructor/
generatedInitialize it is necessary.
In a new project (created today) the toolbars are created in
generatedInitialize like this:
Code: Select all
predicates
generatedInitialize : ().
clauses
generatedInitialize():-
setText("testGUI"),
setDecoration(titlebar([closebutton(),maximizebutton(),minimizebutton()])),
setBorder(sizeBorder()),
setState([wsf_ClipSiblings]),
whenCreated({ :- projectToolbar::create(getVpiWindow()), statusLine::create(getVpiWindow()) }),
addSizeListener({ :- vpiToolbar::resize(getVpiWindow()) }),
setMdiProperty(mdiProperty),
menuSet(resMenu(resourceIdentifiers::id_TaskMenu)),
addShowListener(onShow),
addSizeListener(onSizeChanged),
addDestroyListener(onDestroy),
addMenuItemListener(resourceIdentifiers::id_help_about, onHelpAbout),
addMenuItemListener(resourceIdentifiers::id_file_exit, onFileExit).