<?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 Re: IMPORTANT! How to make a Pallete dialog by C++ Class in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-How-to-make-a-Palette-dialog-by-C-Class/m-p/283263#M4832</link>
    <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
you can read about this in the API DevKit documentation's "New API features in ArchiCAD 18" topic:
&lt;BLOCKQUOTE&gt;Resource chain is gone (also ACAPI_UseOwnResModule() and ACAPI_ResetResModule() along with it)&lt;BR /&gt;
OS X internally maintained a stack of open resource files called the resource chain. Whenever you want to load a resource, the system searched downwards in this stack to find the resource in any of the open resource files below the current one.&lt;BR /&gt;
We removed that implicit mechanism; you'll have to specify each and every time the resource module explicitly (usually with ACAPI_GetOwnResModule()).&lt;/BLOCKQUOTE&gt;
So you should remove all of your ACAPI_UseOwnResModule() and ACAPI_ResetResModule() calls and then that problem will be solved &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_smile.gif" style="display : inline;" /&gt;&lt;BR /&gt;
&lt;BR /&gt;
Constructor of DG::Palette has been changed (and all of other DG constructors too). Now you should use ACAPI_GetOwnResModule() when calling that constructor.&lt;BR /&gt;
So please change this line in your code:
&lt;PRE&gt;Palette::Palette(short resId) : DG::Palette(resId, PaletteGuid),&lt;/PRE&gt;
to this:
&lt;PRE&gt;Palette::Palette(short resId) : DG::Palette(ACAPI_GetOwnResModule(), resId, ACAPI_GetOwnResModule(), PaletteGuid),&lt;/PRE&gt;
(You can find DG::Palette::Palette constructor in DGDialog.hpp header file.)&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Tibor</description>
    <pubDate>Mon, 20 Jul 2015 10:45:44 GMT</pubDate>
    <dc:creator>Tibor Lorantfy</dc:creator>
    <dc:date>2015-07-20T10:45:44Z</dc:date>
    <item>
      <title>[SOLVED] How to make a Palette dialog by C++ Class</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-How-to-make-a-Palette-dialog-by-C-Class/m-p/283262#M4831</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Hi there&lt;BR /&gt;&lt;BR /&gt;This question already exist in forum but there are some functions which are not exist in DevKit 18 so please help.&lt;BR /&gt;&lt;BR /&gt;Here is the code I'm using&lt;BR /&gt;
&lt;PRE&gt;Code:

//////////////////////////////////////////////////////////////////////// 
// Addon.cpp 


// --- Addon ------------------------------------------------------------ 

... 

#include "Palette.h" 

... 

GSErrCode __ACENV_CALL   Initialize (void) 
{ 
   GSErrCode err = NoError; 

   // Prevent the add-on auto-unloading 
        ACAPI_KeepInMemory(1); 

   // Install menu handler 
   err = ACAPI_Install_MenuHandler (32500, APIMenuCommandProc_32500); 

   ... 


   return err; 
}      /* Initialize */ 


GSErrCode __ACENV_CALL   FreeData (void) 
{ 
   ...    

   Palette::DeleteInstance(); 

   return NoError; 
}      /* FreeData */ 



GSErrCode __ACENV_CALL APIMenuCommandProc_32500 (const API_MenuParams *menuParams) 
{ 
   DBPrintf ("Test::APIMenuCommandProc_32500() %d/%d\n", menuParams-&amp;gt;menuItemRef.menuResID, menuParams-&amp;gt;menuItemRef.itemIndex); 
   ACAPI_KeepInMemory(1); 
   Palette::ToggleVisibility(); 
   return NoError; 
} 



//////////////////////////////////////////////////////////////////////// 
// Palette.h 

#pragma once; 

// --- Palette ------------------------------------------------------------ 

class Palette: public DG::Palette 
{ 
  friend class PaletteObserver; 

private: 
   static Palette* m_pPalette; 
  static PaletteObserver* m_pPaletteObserver; 

  enum { 
     CloseButtonId      = 1 
  }; 

DG::Button closeButton;  

private: 
  Palette(short resId); 

public: 
  ~Palette(); 
  void SelectionChanged(const API_Neig *selElemNeig); 


static Palette&amp;amp; GetInstance(); 
static bool HasInstance(); 
static void DeleteInstance(); 
static void ToggleVisibility(); 

}; 

// --- PaletteObserver ------------------------------------------------------------ 

class PaletteObserver: private DG::PanelObserver, 
  public  DG::ButtonItemObserver, 
  public  DG::CompoundItemObserver 
{ 
private: 
  Palette*   m_palette; 
public: 
  PaletteObserver (Palette* palette); 
  ~PaletteObserver(); 
  virtual void   SourceDestroyed (GS::EventSource* evSource); 
  virtual void   PanelOpened (const DG::PanelOpenEvent&amp;amp; ev); 
  virtual void   PanelCloseRequested (const DG::PanelCloseRequestEvent&amp;amp; ev, bool* accepted); 
  virtual void   PanelClosed (const DG::PanelCloseEvent&amp;amp; ev); 
  virtual void   PanelResized (const DG::PanelResizeEvent&amp;amp; ev); 
  virtual void   ButtonClicked (const DG::ButtonClickEvent&amp;amp; ev); 
}; 


//////////////////////////////////////////////////////////////////////// 
// Palette.cpp 

#if !defined (ACExtension) 
#define   ACExtension 
#endif 

#if defined (_MSC_VER) 
   #if !defined (WINDOWS) 
      #define WINDOWS 
   #endif 
#endif 

#if defined (WINDOWS) 
   #include "Win32Interface.hpp" 
   #pragma warning (disable: 4068) 
#endif 

// ------------------------------ Includes ------------------------------------- 

#include   &amp;lt;stdio.h&amp;gt; 
#include   &amp;lt;math.h&amp;gt; 
#include   &amp;lt;string.h&amp;gt; 

#if defined (macintosh) 
#include   &amp;lt;MacTypes.h&amp;gt; 
#endif 

#include   "DG.h" 
#include   "DGModule.hpp" 

#include   "ACAPinc.h" 
#include   "APICommon.h"   // also includes GSRoot.hpp 


#include "Palette.h" 

static GS::Guid   PaletteGuid  ("{9597C98D-95BD-48d9-9999-C2297834806B}"); 

static GSErrCode __ACENV_CALL   ModelessWindowCallBack (long referenceID, API_PaletteMessageID messageID) 
{ 
   if (Palette::HasInstance() &amp;amp;&amp;amp; referenceID == Palette::GetInstance().GetId()) { 
      switch (messageID) { 
      case APIPalMsg_ClosePalette:    
          Palette::GetInstance().SendCloseRequest();  
         break; 
      case APIPalMsg_HidePalette_Begin:    
         break; 
      case APIPalMsg_HidePalette_End:    
         break; 
      case APIPalMsg_DisableItems_Begin:    
         break; 
      case APIPalMsg_DisableItems_End:    
               break; 
     } 
   } 
   return NoError; 
} 

// --- Palette ------------------------------------------------------------ 

/*static*/ Palette* Palette::m_pPalette = NULL; 
/*static*/ PaletteObserver* Palette::m_pPaletteObserver = NULL; 

/////////////////////////////////////////// 

/*static*/ Palette&amp;amp; Palette::GetInstance() 
{ 
   if (!m_pPalette) { 
     GSResModule actResModule = ACAPI_UseOwnResModule (); 
      m_pPalette = new Palette(32420);  
     ACAPI_ResetResModule (actResModule); 
       m_pPaletteObserver = new PaletteObserver(m_pPalette); 
   } 
   return *m_pPalette; 
} 

/*static*/ bool Palette::HasInstance() 
{ 
   return m_pPalette != NULL; 
} 

/*static*/ void Palette::DeleteInstance() 
{ 
   DBASSERT(m_pPalette != NULL); 
   if (m_pPalette != NULL) { 
      delete m_pPalette; 
      m_pPalette = NULL; 
   } 
   if (m_pPaletteObserver != NULL) { 
      delete m_pPaletteObserver; 
      m_pPaletteObserver = NULL; 
   } 
} 

/*static*/ void Palette::ToggleVisibility() { 
   if (m_pPalette != NULL &amp;amp;&amp;amp; m_pPalette-&amp;gt;IsVisible()) { 
      m_pPalette-&amp;gt;EndEventProcessing(); 
      m_pPalette-&amp;gt;Hide(); 
   } else { 
          Palette::GetInstance().BeginEventProcessing(); 
          m_pPalette-&amp;gt;Show(); 
   } 
} 

////////////////////////////////////////////////////////// 

Palette::Palette(short resId) : DG::Palette(resId, PaletteGuid), 
 closeButton (GetReference (), CloseButtonId) 
{ 
   ACAPI_RegisterModelessWindow (GetId(), ModelessWindowCallBack, 
          API_PalEnabled_FloorPlan + 
               API_PalEnabled_Section + 
               API_PalEnabled_Detail + 
               API_PalEnabled_Layout + 
               API_PalEnabled_3D 
    ); 
} 


Palette::~Palette () 
{ 
   ACAPI_UnregisterModelessWindow (GetId()); 
} 

void Palette::SelectionChanged(const API_Neig *selElemNeig) 
{ 
  if (selElemNeig-&amp;gt;neigID != APINeig_None) 
   { 
      DBPrintf("Last selected element: NeigID %d; guid: %s, inIndex: %d\n", 
               selElemNeig-&amp;gt;neigID, (const char *) APIGuid2GSGuid (selElemNeig-&amp;gt;guid).ToUniString ().ToCStr (), 
               selElemNeig-&amp;gt;inIndex); 
         closeButton.Enable(); 
   } else { 
      DBPrintf("All elements deselected\n"); 
         closeButton.Disable(); 
   } 
} 





// --- PaletteObserver ------------------------------------------------------------ 

PaletteObserver::PaletteObserver (Palette* palette) 
: m_palette (palette) 
{ 
   if (DBVERIFY (m_palette != NULL)) { 
      palette-&amp;gt;Attach (*this); 
      AttachToAllItems (*m_palette); 
   } 
} 


PaletteObserver::~PaletteObserver () 
{ 
   if (m_palette != NULL) { 
      m_palette-&amp;gt;Detach (*this); 
      DetachFromAllItems (*m_palette); 
   } 
} 


// ... Public methods .......................................................... 

void PaletteObserver::SourceDestroyed (GS::EventSource* evSource) 
{ 
   if (evSource == m_palette) { 
      //MarkAsFinished (); 
      //notesObserver-&amp;gt;FindPaletteDestroyed (); 
      //palette = NULL; 
   } 
} 


// ... Dialog notifications .................................................... 

void PaletteObserver::PanelOpened (const DG::PanelOpenEvent&amp;amp; /*ev*/) 
{ 
   SetMenuItemMark(32500, 1, true); 

   /*palette-&amp;gt;findEdit.SetText (palette-&amp;gt;findData-&amp;gt;findText); 
   palette-&amp;gt;replaceEdit.SetText (palette-&amp;gt;findData-&amp;gt;replaceText); 
   FindValidate (); 

   if (palette-&amp;gt;findData-&amp;gt;findWholeWord) 
      palette-&amp;gt;wholeWordCheck.Check (); 
   if (palette-&amp;gt;findData-&amp;gt;findMatchCase) 
      palette-&amp;gt;matchCaseCheck.Check (); 
   if (palette-&amp;gt;findData-&amp;gt;findWrap) 
      palette-&amp;gt;wrapCheck.Check (); 

   if (palette-&amp;gt;findData-&amp;gt;findUp) 
      palette-&amp;gt;upRadio.Select (); 
   else 
      palette-&amp;gt;downRadio.Select (); 

   palette-&amp;gt;findEdit.SetFocus ();*/ 
} 


void PaletteObserver::PanelCloseRequested (const DG::PanelCloseRequestEvent&amp;amp; /*ev*/, bool* /*accepted*/) 
{ 
   m_palette-&amp;gt;EndEventProcessing (); 
} 

void PaletteObserver::PanelClosed (const DG::PanelCloseEvent&amp;amp; /*ev*/) 
{ 
   SetMenuItemMark(32500, 1, false); 
} 

void PaletteObserver::PanelResized (const DG::PanelResizeEvent&amp;amp; ev) 
{ 
   short dh = ev.GetHorizontalChange (); 
   short dv = ev.GetVerticalChange (); 

   m_palette-&amp;gt;BeginMoveResizeItems(); 

   //dialog-&amp;gt;separator.Move (dh, 0); 

   m_palette-&amp;gt;closeButton.Move (dh, dv); 

   m_palette-&amp;gt;EndMoveResizeItems(); 
} 

// ... Dialog item notifications ............................................... 

void   PaletteObserver::ButtonClicked (const DG::ButtonClickEvent&amp;amp; ev) 
{ 
   if (ev.GetSource () == &amp;amp;m_palette-&amp;gt;closeButton) { 
      m_palette-&amp;gt;SendCloseRequest (); 
   } 
} 
&lt;/PRE&gt;
&lt;BR /&gt;And here is the errors&lt;BR /&gt;&lt;BR /&gt;error C3861: 'ACAPI_UseOwnResModule': identifier not found&lt;BR /&gt;error C3861: 'ACAPI_ResetResModule': identifier not found&lt;BR /&gt;error C2664: 'DG::Palette::Palette(const DG::Rect &amp;amp;,DG::Dialog::GrowType,DG::Dialog::CloseType,DG::Dialog::CaptionType,DG::Dialog::FrameType,DG::Dialog::SpecialFeatures)' : cannot convert parameter 1 from 'short' to 'const DG::Rect &amp;amp;'&lt;BR /&gt;Reason: cannot convert from 'short' to 'const DG::Rect'&lt;/DIV&gt;</description>
      <pubDate>Thu, 13 Jul 2023 14:20:52 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-How-to-make-a-Palette-dialog-by-C-Class/m-p/283262#M4831</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-07-13T14:20:52Z</dc:date>
    </item>
    <item>
      <title>Re: IMPORTANT! How to make a Pallete dialog by C++ Class</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-How-to-make-a-Palette-dialog-by-C-Class/m-p/283263#M4832</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
you can read about this in the API DevKit documentation's "New API features in ArchiCAD 18" topic:
&lt;BLOCKQUOTE&gt;Resource chain is gone (also ACAPI_UseOwnResModule() and ACAPI_ResetResModule() along with it)&lt;BR /&gt;
OS X internally maintained a stack of open resource files called the resource chain. Whenever you want to load a resource, the system searched downwards in this stack to find the resource in any of the open resource files below the current one.&lt;BR /&gt;
We removed that implicit mechanism; you'll have to specify each and every time the resource module explicitly (usually with ACAPI_GetOwnResModule()).&lt;/BLOCKQUOTE&gt;
So you should remove all of your ACAPI_UseOwnResModule() and ACAPI_ResetResModule() calls and then that problem will be solved &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_smile.gif" style="display : inline;" /&gt;&lt;BR /&gt;
&lt;BR /&gt;
Constructor of DG::Palette has been changed (and all of other DG constructors too). Now you should use ACAPI_GetOwnResModule() when calling that constructor.&lt;BR /&gt;
So please change this line in your code:
&lt;PRE&gt;Palette::Palette(short resId) : DG::Palette(resId, PaletteGuid),&lt;/PRE&gt;
to this:
&lt;PRE&gt;Palette::Palette(short resId) : DG::Palette(ACAPI_GetOwnResModule(), resId, ACAPI_GetOwnResModule(), PaletteGuid),&lt;/PRE&gt;
(You can find DG::Palette::Palette constructor in DGDialog.hpp header file.)&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Tibor</description>
      <pubDate>Mon, 20 Jul 2015 10:45:44 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-How-to-make-a-Palette-dialog-by-C-Class/m-p/283263#M4832</guid>
      <dc:creator>Tibor Lorantfy</dc:creator>
      <dc:date>2015-07-20T10:45:44Z</dc:date>
    </item>
    <item>
      <title>Re: IMPORTANT! How to make a Pallete dialog by C++ Class</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-How-to-make-a-Palette-dialog-by-C-Class/m-p/283264#M4833</link>
      <description>Thank you for the help.&lt;BR /&gt;
&lt;BR /&gt;
Still I have question.&lt;BR /&gt;
&lt;BR /&gt;
I tried to read documentation. But in documentation's example again with old methods which is not supported by DevKit18. Please kindly give me a small example. So I can understand how to do that with C++ class.</description>
      <pubDate>Mon, 20 Jul 2015 13:35:20 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-How-to-make-a-Palette-dialog-by-C-Class/m-p/283264#M4833</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-07-20T13:35:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a Pallete dialog by C++ Class</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-How-to-make-a-Palette-dialog-by-C-Class/m-p/283265#M4834</link>
      <description>Today I implemented an example palette for you.  &lt;BR /&gt;
Note that this is a minimal example, just to show how to make custom C++ Palette class properly. &lt;BR /&gt;
  &lt;BR /&gt;
&lt;B&gt;GRC&lt;/B&gt;
&lt;PRE&gt;/* Text appearing in the menu */  
  
'STR#' 32500 "Menu strings" {  
/* [   ] */		"Test"  
/* [   ] */		"DG Functions"  
/* [  1] */			"Open Example Palette"  
}  
  
'STR#' 32520 "Prompt strings" {  
/* [   ] */		"Test"  
/* [   ] */		"DG Functions"  
/* [  1] */			"Open Example Palette"  
}  
  
/* ---------------------------------------------------------- Example Palette */  
  
'GDLG'  32590  Palette | hGrow | close	    0    0  160   40  "Test Palette" {  
/* [  1] */ Button					 10   10  140   20	LargePlain  "Hide"  
}  
  
'DLGH'  32590  DLG_32580_Test_Palette {  
1	""					Button_0  
}&lt;/PRE&gt;
&lt;B&gt;ExamplePalette.hpp&lt;/B&gt;
&lt;PRE&gt;// ---------------------------------- Includes ---------------------------------  
  
#include "APIEnvir.h"  
#include	"ACAPinc.h"  
#include	"DG.h"  
#include	"DGModule.hpp"  
  
#include	"DisposableObject.hpp"  
  
  
#define EXAMPLEPALETTE_RESID		32590  
  
// --- ExamplePalette ----------------------------------------------------------  
  
class ExamplePalette:	public	DG::Palette,  
				public	DG::PanelObserver,  
				public	DG::ButtonItemObserver,  
				public	DG::CompoundItemObserver,  
				public	GS::DisposableObject  
{  
private:
	enum {  
		HideButtonId		= 1  
	};  
  
	DG::Button		hideButton;  
  
	ExamplePalette	(GSResModule dialResModule, short resId);  
  
protected:  
	virtual void	PanelOpened		(const DG::PanelOpenEvent&amp;amp; ev) override;  
	virtual void	PanelResized		(const DG::PanelResizeEvent&amp;amp; ev) override;  
	virtual void	PanelCloseRequested	(const DG::PanelCloseRequestEvent&amp;amp; ev, bool* accept) override;  
  
	virtual void	ButtonClicked		(const DG::ButtonClickEvent&amp;amp; ev) override;  
  
public:  
	static const GS::Guid		paletteGuid;  
	static Int32			paletteRefId;  
  
	ExamplePalette		();  
	~ExamplePalette	();  
  
	static GSErrCode __ACENV_CALL	PaletteAPIControlCallBack (Int32 referenceID, API_PaletteMessageID messageID, GS::IntPtr param);  
};  
  
  
// --- ExamplePaletteManager ---------------------------------------------------  
  
class ExamplePaletteManager	:	public	GS::DisposeHandler  
{  
private:  
	ExamplePalette*	examplePalette;  
  
	ExamplePaletteManager	();  
	ExamplePaletteManager	(const ExamplePaletteManager&amp;amp; source);	//disabled

	ExamplePaletteManager	operator=	(const ExamplePaletteManager&amp;amp; source);	//disabled  
  
public:  
	~ExamplePaletteManager					();  
  
	static ExamplePaletteManager&amp;amp;	GetInstance	();  
  
	static void		OpenExamplePalette			();  
	static void		CloseExamplePalette			();  
	static bool		IsExamplePaletteOpened		();  
  
	ExamplePalette* GetExamplePalette			();  
  
	virtual void	DisposeRequested		(GS::DisposableObject&amp;amp; source) override;  
};&lt;/PRE&gt;  &lt;BR /&gt;
  &lt;BR /&gt;
&lt;B&gt;ExamplePalette.cpp&lt;/B&gt;
&lt;PRE&gt;// ---------------------------------- Includes ---------------------------------  
  
#include	"ExamplePalette.hpp"
  
//------------------------------ Class ExamplePalette --------------------------  
  
const GS::Guid	ExamplePalette::paletteGuid ("{D8A0A01F-1184-40F2-B8A8-28CF30714FA4}");  
Int32		ExamplePalette::paletteRefId = (Int32) GS::GenerateHashValue (ExamplePalette::paletteGuid);  
  
  
ExamplePalette::ExamplePalette ():  
	DG::Palette	(ACAPI_GetOwnResModule (), EXAMPLEPALETTE_RESID, ACAPI_GetOwnResModule (), paletteGuid),  
  
	hideButton	(GetReference (), HideButtonId)  
{  
	Attach (*this);  
	AttachToAllItems (*this);  
  
	SetDefaultGarbageCollector ();  
	SetDisposeHandler (ExamplePaletteManager::GetInstance ());  
}  
  
  
ExamplePalette::~ExamplePalette ()  
{  
	Detach (*this);  
	DetachFromAllItems (*this);
}  
  
  
void ExamplePalette::PanelOpened (const DG::PanelOpenEvent&amp;amp; /*ev*/)  
{  
}  
  
  
void ExamplePalette::PanelResized (const DG::PanelResizeEvent&amp;amp; ev)  
{  
	short vGrow = ev.GetVerticalChange ();  
	short hGrow = ev.GetHorizontalChange ();  
  
	if (vGrow != 0 || hGrow != 0) {  
		BeginMoveResizeItems ();  
  
		hideButton.Move (hGrow, vGrow);  
  
		EndMoveResizeItems ();  
	}  
}  
  
  
void ExamplePalette::PanelCloseRequested (const DG::PanelCloseRequestEvent&amp;amp; ev, bool* /*accept*/)  
{  
	if (ev.GetSource () != this)  
		return;  
  
	Hide				();  
	EndEventProcessing	();  
	MarkAsDisposable	();  
}  
  
  
void ExamplePalette::ButtonClicked (const DG::ButtonClickEvent&amp;amp; ev)  
{  
	if (ev.GetSource () == &amp;amp;hideButton) {  
		Hide ();  
	}  
}  
  
  
GSErrCode __ACENV_CALL	ExamplePalette::PaletteAPIControlCallBack (Int32 referenceID, API_PaletteMessageID messageID, GS::IntPtr param)  
{  
	GSErrCode	err = NoError;  
  
	if (referenceID == paletteRefId) {  
		switch (messageID) {  
			case APIPalMsg_OpenPalette:  
				ExamplePaletteManager::OpenExamplePalette ();  
				break;  
  
			case APIPalMsg_ClosePalette:  
				ExamplePaletteManager::CloseExamplePalette ();  
				break;  
  
			case APIPalMsg_HidePalette_Begin:  
				if (ExamplePaletteManager::IsExamplePaletteOpened ())  
					ExamplePaletteManager::GetInstance ().GetExamplePalette ()-&amp;gt;Hide ();  
				break;  
  
			case APIPalMsg_HidePalette_End:  
				if (ExamplePaletteManager::IsExamplePaletteOpened ())  
					ExamplePaletteManager::GetInstance ().GetExamplePalette ()-&amp;gt;Show ();  
				break;  
  
			case APIPalMsg_DisableItems_Begin:  
				if (ExamplePaletteManager::IsExamplePaletteOpened ())  
					ExamplePaletteManager::GetInstance ().GetExamplePalette ()-&amp;gt;DisableItems ();  
				break;  
  
			case APIPalMsg_DisableItems_End:  
				if (ExamplePaletteManager::IsExamplePaletteOpened ())  
					ExamplePaletteManager::GetInstance ().GetExamplePalette ()-&amp;gt;EnableItems ();  
				break;  
  
			case APIPalMsg_IsPaletteVisible:  
				*(reinterpret_cast&amp;lt;bool*&amp;gt; (param)) = (ExamplePaletteManager::IsExamplePaletteOpened () &amp;amp;&amp;amp; ExamplePaletteManager::GetInstance ().GetExamplePalette ()-&amp;gt;IsVisible ());  
				break;  
  
			default:  
				break;  
		}  
	}  
  
	return err;  
}  
  
  
//-------------------------- Class ExamplePaletteManager -----------------------  
  
ExamplePaletteManager&amp;amp;	ExamplePaletteManager::GetInstance	()  
{  
	static ExamplePaletteManager instance;  
  
	return instance;  
}  
  
  
ExamplePaletteManager::ExamplePaletteManager () :  
	examplePalette (NULL)  
{  
}  
  
  
ExamplePaletteManager::~ExamplePaletteManager ()  
{  
	if (DBERROR (examplePalette != NULL)) {  
		examplePalette-&amp;gt;EndEventProcessing ();  
		delete examplePalette;  
		examplePalette = NULL;  
	}  
}  
  
  
void	ExamplePaletteManager::OpenExamplePalette ()  
{  
	ExamplePaletteManager&amp;amp; manager = GetInstance ();  
  
	if (manager.examplePalette == NULL) {  
		manager.examplePalette = new ExamplePalette ();  
		if (DBERROR (manager.examplePalette == NULL))  
			return;  
	}  
  
	manager.examplePalette-&amp;gt;BeginEventProcessing ();  
	manager.examplePalette-&amp;gt;Show ();  
}  
  
  
void	ExamplePaletteManager::CloseExamplePalette ()  
{  
	ExamplePaletteManager&amp;amp; manager = GetInstance ();  
  
	if (manager.examplePalette == NULL)  
		return;  
  
	manager.examplePalette-&amp;gt;Hide ();  
	manager.examplePalette-&amp;gt;EndEventProcessing ();  
	delete manager.examplePalette;  
	manager.examplePalette = NULL;  
}  
  
  
bool	ExamplePaletteManager::IsExamplePaletteOpened (void)  
{  
	return GetInstance ().examplePalette != NULL;  
}  
  
  
void	ExamplePaletteManager::DisposeRequested (GS::DisposableObject&amp;amp; source)  
{  
	ExamplePaletteManager&amp;amp; manager = GetInstance ();  
	if (&amp;amp;source == manager.examplePalette) {  
		manager.examplePalette = NULL;  
	}  
}  
  
  
ExamplePalette* ExamplePaletteManager::GetExamplePalette ()  
{  
	return this-&amp;gt;examplePalette;  
}&lt;/PRE&gt;

&lt;B&gt;Main.cpp&lt;/B&gt;
&lt;PRE&gt;// ---------------------------------- Includes ---------------------------------

#include "APIEnvir.h"
#include	"ACAPinc.h"
#include	"APICommon.h"

#include	"ExamplePalette.hpp"

// -----------------------------------------------------------------------------
// Function to open the Example Palette
// -----------------------------------------------------------------------------

static void		Open_ExamplePalette (void)
{
	if (!ExamplePaletteManager::IsExamplePaletteOpened ())
		ExamplePaletteManager::OpenExamplePalette ();
	return;
}


// -----------------------------------------------------------------------------
// Handles menu commands
// -----------------------------------------------------------------------------

GSErrCode __ACENV_CALL MenuCommandHandler (const API_MenuParams *menuParams)
{
	switch (menuParams-&amp;gt;menuItemRef.menuResID) {
		case 32500:
			switch (menuParams-&amp;gt;menuItemRef.itemIndex) {
				case 1:	Open_ExamplePalette ();				break;
			}
			break;
	}

	return NoError;
}		// MenuCommandHandler


// -----------------------------------------------------------------------------
// Interface definitions
// -----------------------------------------------------------------------------

GSErrCode	__ACENV_CALL	RegisterInterface (void)
{
	GSErrCode err;

	err = ACAPI_Register_Menu (32500, 32520, MenuCode_UserDef, MenuFlag_Default);
	if (err != NoError)
		DBPrintf ("DG_Test:: RegisterInterface() ACAPI_Register_Menu failed\n");

	return err;
}		// RegisterInterface


// -----------------------------------------------------------------------------
// Called when the Add-On has been loaded into memory
// to perform an operation
// -----------------------------------------------------------------------------

GSErrCode	__ACENV_CALL Initialize	(void)
{
	GSErrCode err = ACAPI_Install_MenuHandler (32500, MenuCommandHandler);
	if (err != NoError)
		DBPrintf ("DG_Test:: Initialize() ACAPI_Install_MenuHandler failed\n");

	err = ACAPI_RegisterModelessWindow (ExamplePalette::paletteRefId, ExamplePalette::PaletteAPIControlCallBack,
										API_PalEnabled_FloorPlan + API_PalEnabled_3D + API_PalEnabled_Layout,
										GSGuid2APIGuid (ExamplePalette::paletteGuid));
	if (err != NoError)
		DBPrintf ("DG_Test:: Initialize() ACAPI_RegisterModelessWindow failed\n");

	return err;
}		// Initialize


// -----------------------------------------------------------------------------
// FreeData
//		called when the Add-On is going to be unloaded
// -----------------------------------------------------------------------------

GSErrCode __ACENV_CALL	FreeData (void)
{
	ACAPI_UnregisterModelessWindow (ExamplePalette::paletteRefId);

	return NoError;
}		// FreeData
&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Jul 2015 14:13:23 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-How-to-make-a-Palette-dialog-by-C-Class/m-p/283265#M4834</guid>
      <dc:creator>Tibor Lorantfy</dc:creator>
      <dc:date>2015-07-21T14:13:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a Pallete dialog by C++ Class</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-How-to-make-a-Palette-dialog-by-C-Class/m-p/283266#M4835</link>
      <description>Thank you very much.&lt;BR /&gt;
This is what I need.</description>
      <pubDate>Wed, 22 Jul 2015 12:15:37 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-How-to-make-a-Palette-dialog-by-C-Class/m-p/283266#M4835</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-07-22T12:15:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a Pallete dialog by C++ Class</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-How-to-make-a-Palette-dialog-by-C-Class/m-p/321298#M4836</link>
      <description>&lt;P&gt;nice&lt;/P&gt;</description>
      <pubDate>Mon, 22 Nov 2021 15:24:25 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-How-to-make-a-Palette-dialog-by-C-Class/m-p/321298#M4836</guid>
      <dc:creator>Csanyi Bence</dc:creator>
      <dc:date>2021-11-22T15:24:25Z</dc:date>
    </item>
  </channel>
</rss>

