<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic [GUI] DG::Palette disappears in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/GUI-DG-Palette-disappears/m-p/80243#M7607</link>
    <description>&lt;DIV class="actalk-migrated-content"&gt;Hello, &lt;BR /&gt;&lt;BR /&gt;When i use DG::ModalDialog and run method Invoke() my GUI stays on top of the window and message processing system works fine. But when i use DG::Palette (i need it, because I have to have possibility to select items during plug-in is running) there is no Invoke method:/ I've try:
&lt;PRE&gt;GDLInterface gdlInterface; 
	gdlInterface.Activate(); 
	gdlInterface.BeginEventProcessing(); 
	gdlInterface.Show(); 
	gdlInterface.BringToFront();&lt;/PRE&gt;
&lt;BR /&gt;GDLInterface inherits from DG::Palette. &lt;BR /&gt;&lt;FONT color="red"&gt;BUT my interface disappears immediately after in shows up. &lt;/FONT&gt;&lt;BR /&gt;How can I use palette? Should it be running in thread?&lt;BR /&gt;GUI is turned on from menu.&lt;BR /&gt;&lt;BR /&gt;Maciek&lt;/DIV&gt;</description>
    <pubDate>Fri, 04 Aug 2023 14:16:30 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2023-08-04T14:16:30Z</dc:date>
    <item>
      <title>[GUI] DG::Palette disappears</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/GUI-DG-Palette-disappears/m-p/80243#M7607</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Hello, &lt;BR /&gt;&lt;BR /&gt;When i use DG::ModalDialog and run method Invoke() my GUI stays on top of the window and message processing system works fine. But when i use DG::Palette (i need it, because I have to have possibility to select items during plug-in is running) there is no Invoke method:/ I've try:
&lt;PRE&gt;GDLInterface gdlInterface; 
	gdlInterface.Activate(); 
	gdlInterface.BeginEventProcessing(); 
	gdlInterface.Show(); 
	gdlInterface.BringToFront();&lt;/PRE&gt;
&lt;BR /&gt;GDLInterface inherits from DG::Palette. &lt;BR /&gt;&lt;FONT color="red"&gt;BUT my interface disappears immediately after in shows up. &lt;/FONT&gt;&lt;BR /&gt;How can I use palette? Should it be running in thread?&lt;BR /&gt;GUI is turned on from menu.&lt;BR /&gt;&lt;BR /&gt;Maciek&lt;/DIV&gt;</description>
      <pubDate>Fri, 04 Aug 2023 14:16:30 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/GUI-DG-Palette-disappears/m-p/80243#M7607</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-08-04T14:16:30Z</dc:date>
    </item>
    <item>
      <title>Re: [GUI] DG::Palette disappears</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/GUI-DG-Palette-disappears/m-p/80244#M7608</link>
      <description>Hello.   &lt;BR /&gt;
   &lt;BR /&gt;
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.   &lt;BR /&gt;
   
&lt;PRE&gt;GSErrCode __ACENV_CALL	CommandHandler (const API_MenuParams * params)   
{   
	switch(params-&amp;gt;menuItemRef.menuResID)   
	{   
	case 32500:   
		switch(params-&amp;gt;menuItemRef.itemIndex)   
		{   
		case 1:   
			{ // &amp;lt;-- 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 ()&lt;/PRE&gt;   &lt;BR /&gt;
I've try to use pointers, but ArchiCAD crashes.   &lt;BR /&gt;
   &lt;BR /&gt;
I haven't found any functions, like RegisterPalette, and I really need to make it working.   &lt;BR /&gt;
Did anyone wrote plugin which uses palette as main window and make it working??  &lt;BR /&gt;
  &lt;BR /&gt;
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...</description>
      <pubDate>Tue, 27 Nov 2007 18:47:52 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/GUI-DG-Palette-disappears/m-p/80244#M7608</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-11-27T18:47:52Z</dc:date>
    </item>
    <item>
      <title>Re: [GUI] DG::Palette disappears</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/GUI-DG-Palette-disappears/m-p/80245#M7609</link>
      <description>&lt;BLOCKQUOTE&gt;bamboos wrote:&lt;BR /&gt;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.&lt;BR /&gt;
[...]&lt;BR /&gt;
I've try to use pointers, but ArchiCAD crashes.    &lt;BR /&gt;
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...&lt;/BLOCKQUOTE&gt;
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.&lt;BR /&gt;
&lt;BR /&gt;
You're on the right track using a pointer, but I suspect you haven't allocated memory for the object by using 'new'. If your class is called 'GDL Interface', you would create an instance with something like &lt;PRE&gt;GDLInterface* interfacePalette = new GDLInterface;&lt;/PRE&gt;
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 &lt;PRE&gt; GDLInterface* interfacePalette = GDLInterface::getInstance();&lt;/PRE&gt;
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.</description>
      <pubDate>Tue, 27 Nov 2007 22:05:26 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/GUI-DG-Palette-disappears/m-p/80245#M7609</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2007-11-27T22:05:26Z</dc:date>
    </item>
    <item>
      <title>Re: [GUI] DG::Palette disappears</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/GUI-DG-Palette-disappears/m-p/80246#M7610</link>
      <description>Yes!!! &lt;BR /&gt;
 &lt;BR /&gt;
Ralph Wessel, you helped me a lot. I've try pointers and memory allocation by new, but ArchiCAD crashed. Function ACAPI_KeepInMemory solved the problem. &lt;BR /&gt;
 &lt;BR /&gt;
Thanks again. &lt;BR /&gt;
Maciek</description>
      <pubDate>Wed, 28 Nov 2007 01:53:36 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/GUI-DG-Palette-disappears/m-p/80246#M7610</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-11-28T01:53:36Z</dc:date>
    </item>
  </channel>
</rss>

