2007-11-11
05:49 AM
- last edited on
2023-08-04
04:16 PM
by
Doreena Deng
GDLInterface gdlInterface; gdlInterface.Activate(); gdlInterface.BeginEventProcessing(); gdlInterface.Show(); gdlInterface.BringToFront();
2007-11-27 07:47 PM
GSErrCode __ACENV_CALL CommandHandler (const API_MenuParams * params)
{
switch(params->menuItemRef.menuResID)
{
case 32500:
switch(params->menuItemRef.itemIndex)
{
case 1:
{ // <-- here Palette should show
DG::Rect rect;
rect.Set(10, 10, 100, 100);
DG::Palette palette(rect);
palette.BeginEventProcessing();
palette.Show();
// here destructor works, like it should, and palette closes
}
}
}
return NoError;
} // CommandHandler () 2007-11-27 11:05 PM
bamboos wrote:I'm guessing the reason for the problem is that the palette object has to persist outside of the scope of the menu-handler callback. Modal dialogs don't have this problem because you're finished with the dialog before returning from the callback.
I still haven't found solution of my problem. These objects for creating dialog boxes are great. But only for modal dialogs. With Palette which inherits from ModelessBase it's not.
[...]
I've try to use pointers, but ArchiCAD crashes.
Did anyone wrote plugin which uses palette as main window and make it working?? Main problem is that I wrote a lot of code which uses object oriented dialog manager. It works fine with DG::ModalDialog, but with DG::Palette don't, because Palette is destroyed right after it was created... Please help...
GDLInterface* interfacePalette = new GDLInterface;You also need to make sure the pointer is a global variable (initialised to 0), perhaps a static member variable of the GDLInterface class, and keep the constructor private so you get an instance with something like
GDLInterface* interfacePalette = GDLInterface::getInstance();Finally, make sure ArchiCAD knows your add-on has to remain loaded (see ACAPI_KeepInMemory) and the instance is deleted before the add-on shuts down.
2007-11-28 02:53 AM