<?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: Modeless or Palette Dialog help in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/Modeless-or-Palette-Dialog-help/m-p/215902#M5362</link>
    <description>Hi, &lt;BR /&gt;
 &lt;BR /&gt;
I think you forgot to call ACAPI_RegisterModelessWindow function in DG_MSG_INIT, that's why you won't get any further messages. &lt;BR /&gt;
I wrote you an example code to show a simple palette with 2 buttons: &lt;BR /&gt;
 
&lt;PRE&gt;// Note that dialID could be different from dialog's resourceID 
static short	myDialID = 0; 
 
// ----------------------------------------------------------------------------- 
// 
// ----------------------------------------------------------------------------- 
static GSErrCode __ACENV_CALL	PaletteAPIControlCallBack (Int32 referenceID, API_PaletteMessageID messageID, GS::IntPtr /*param*/) 
{ 
	if (referenceID == myDialID) { 
		switch (messageID) { 
			case APIPalMsg_ClosePalette:		DGModelessClose (myDialID); 
												break; 
			case APIPalMsg_HidePalette_Begin:	DGHideModelessDialog (myDialID); 
												break; 
			case APIPalMsg_HidePalette_End:		DGShowModelessDialog (myDialID, DG_DF_FIRST); 
												break; 
			case APIPalMsg_DisableItems_Begin: 
			case APIPalMsg_DisableItems_End:	// actually do nothing, because the input finish functionality the buttons have to stay enabled 
			case APIPalMsg_IsPaletteVisible: 
			case APIPalMsg_OpenPalette:			break; 
		} 
	} 
 
	return NoError; 
} 
 
// ----------------------------------------------------------------------------- 
// 'GDLG' resource in (RINT) .grc file 
// ----------------------------------------------------------------------------- 
 
'GDLG'  32400  Palette | leftCaption | grow | close      0    0  196   28  "Example Palette" { 
/* [  1] */ Button				  88    4   70   20	LargePlain  "Close" 
/* [  2] */ Button				   8    4   70   20	LargePlain  "Update" 
} 
 
const short CloseButtonID	= 1; 
const short UpdateButtonID	= 2; 
 
// ----------------------------------------------------------------------------- 
// Callback function for the palette 
// ----------------------------------------------------------------------------- 
 
static short DGCALLBACK CntlDlgCallBack (short message, short dialID, short item, DGUserData /*userData*/, DGMessageData msgData) 
{ 
	switch (message) { 
		case DG_MSG_INIT: 
			DGSetFocus (dialID, DG_NO_ITEM); 
 
			if (ACAPI_RegisterModelessWindow (dialID, PaletteAPIControlCallBack, 
						API_PalEnabled_FloorPlan + API_PalEnabled_Section + API_PalEnabled_Elevation + 
						API_PalEnabled_InteriorElevation + API_PalEnabled_Detail + API_PalEnabled_Worksheet + API_PalEnabled_3D + API_PalEnabled_Layout) != NoError) 
				DBPrintf ("ACAPI_RegisterModelessWindow failed\n"); 
			break; 
 
		case DG_MSG_ACTIVATE:		break; 
		case DG_MSG_UPDATE:			break; 
		case DG_MSG_CHANGE:			break; 
		case DG_MSG_DOUBLECLICK:	break; 
 
		case DG_MSG_CLICK: 
			switch (item) { 
				case UpdateButtonID:	// handle update button click event! 
										break; 
				case CloseButtonID: 
				case DG_CLOSEBOX: 
						return item;	// this will result in a DG_MSG_CLOSE message 
			} 
			break; 
 
		case DG_MSG_GROW: 
			{ 
				short	vgrow = DGGetVGrow (msgData); 
				short	hgrow = DGGetHGrow (msgData); 
				DGBeginMoveGrowItems (dialID); 
				DGMoveItem (dialID, NavCloseButton, hgrow, vgrow); 
				DGMoveItem (dialID, NavUpdateButton, hgrow, vgrow); 
				DGEndMoveGrowItems (dialID); 
			} 
			break; 
 
		case DG_MSG_CLOSE:
			ACAPI_UnregisterModelessWindow (myDialID); 
			myDialID = 0; 
			break; 
 
		default: 
			break; 
	} 
 
	return (0); 
}		// CntlDlgCallBack 
 
// ----------------------------------------------------------------------------- 
// Initialize/open our palette 
// ----------------------------------------------------------------------------- 
 
static bool		Do_PaletteInit (void) 
{ 
	if (myDialID == 0 || !DGIsDialogOpen (myDialID)) 
		myDialID = DGModelessInit (ACAPI_GetOwnResModule (), 32400, ACAPI_GetOwnResModule (), CntlDlgCallBack, NULL, 1); 
 
	return myDialID != 0; 
}		// Do_PaletteInit&lt;/PRE&gt; &lt;BR /&gt;
 &lt;BR /&gt;
Regards, &lt;BR /&gt;
Tibor</description>
    <pubDate>Thu, 13 Nov 2014 21:59:06 GMT</pubDate>
    <dc:creator>Tibor Lorantfy</dc:creator>
    <dc:date>2014-11-13T21:59:06Z</dc:date>
    <item>
      <title>Modeless or Palette Dialog help</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Modeless-or-Palette-Dialog-help/m-p/215901#M5361</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Hi&lt;BR /&gt;hope someone can help me with a Modeless or Palette Example Code.&lt;BR /&gt;I understand how to create a modal dialog but not modeless/palette. I want a palette dialog to have buttons. so far I can't get the dialog to response to the button click event. my code goes to the DG_MSG_INIT of the callback than leaves the function altogether never to return.&lt;/DIV&gt;</description>
      <pubDate>Wed, 12 Jul 2023 18:50:33 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Modeless-or-Palette-Dialog-help/m-p/215901#M5361</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-07-12T18:50:33Z</dc:date>
    </item>
    <item>
      <title>Re: Modeless or Palette Dialog help</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Modeless-or-Palette-Dialog-help/m-p/215902#M5362</link>
      <description>Hi, &lt;BR /&gt;
 &lt;BR /&gt;
I think you forgot to call ACAPI_RegisterModelessWindow function in DG_MSG_INIT, that's why you won't get any further messages. &lt;BR /&gt;
I wrote you an example code to show a simple palette with 2 buttons: &lt;BR /&gt;
 
&lt;PRE&gt;// Note that dialID could be different from dialog's resourceID 
static short	myDialID = 0; 
 
// ----------------------------------------------------------------------------- 
// 
// ----------------------------------------------------------------------------- 
static GSErrCode __ACENV_CALL	PaletteAPIControlCallBack (Int32 referenceID, API_PaletteMessageID messageID, GS::IntPtr /*param*/) 
{ 
	if (referenceID == myDialID) { 
		switch (messageID) { 
			case APIPalMsg_ClosePalette:		DGModelessClose (myDialID); 
												break; 
			case APIPalMsg_HidePalette_Begin:	DGHideModelessDialog (myDialID); 
												break; 
			case APIPalMsg_HidePalette_End:		DGShowModelessDialog (myDialID, DG_DF_FIRST); 
												break; 
			case APIPalMsg_DisableItems_Begin: 
			case APIPalMsg_DisableItems_End:	// actually do nothing, because the input finish functionality the buttons have to stay enabled 
			case APIPalMsg_IsPaletteVisible: 
			case APIPalMsg_OpenPalette:			break; 
		} 
	} 
 
	return NoError; 
} 
 
// ----------------------------------------------------------------------------- 
// 'GDLG' resource in (RINT) .grc file 
// ----------------------------------------------------------------------------- 
 
'GDLG'  32400  Palette | leftCaption | grow | close      0    0  196   28  "Example Palette" { 
/* [  1] */ Button				  88    4   70   20	LargePlain  "Close" 
/* [  2] */ Button				   8    4   70   20	LargePlain  "Update" 
} 
 
const short CloseButtonID	= 1; 
const short UpdateButtonID	= 2; 
 
// ----------------------------------------------------------------------------- 
// Callback function for the palette 
// ----------------------------------------------------------------------------- 
 
static short DGCALLBACK CntlDlgCallBack (short message, short dialID, short item, DGUserData /*userData*/, DGMessageData msgData) 
{ 
	switch (message) { 
		case DG_MSG_INIT: 
			DGSetFocus (dialID, DG_NO_ITEM); 
 
			if (ACAPI_RegisterModelessWindow (dialID, PaletteAPIControlCallBack, 
						API_PalEnabled_FloorPlan + API_PalEnabled_Section + API_PalEnabled_Elevation + 
						API_PalEnabled_InteriorElevation + API_PalEnabled_Detail + API_PalEnabled_Worksheet + API_PalEnabled_3D + API_PalEnabled_Layout) != NoError) 
				DBPrintf ("ACAPI_RegisterModelessWindow failed\n"); 
			break; 
 
		case DG_MSG_ACTIVATE:		break; 
		case DG_MSG_UPDATE:			break; 
		case DG_MSG_CHANGE:			break; 
		case DG_MSG_DOUBLECLICK:	break; 
 
		case DG_MSG_CLICK: 
			switch (item) { 
				case UpdateButtonID:	// handle update button click event! 
										break; 
				case CloseButtonID: 
				case DG_CLOSEBOX: 
						return item;	// this will result in a DG_MSG_CLOSE message 
			} 
			break; 
 
		case DG_MSG_GROW: 
			{ 
				short	vgrow = DGGetVGrow (msgData); 
				short	hgrow = DGGetHGrow (msgData); 
				DGBeginMoveGrowItems (dialID); 
				DGMoveItem (dialID, NavCloseButton, hgrow, vgrow); 
				DGMoveItem (dialID, NavUpdateButton, hgrow, vgrow); 
				DGEndMoveGrowItems (dialID); 
			} 
			break; 
 
		case DG_MSG_CLOSE:
			ACAPI_UnregisterModelessWindow (myDialID); 
			myDialID = 0; 
			break; 
 
		default: 
			break; 
	} 
 
	return (0); 
}		// CntlDlgCallBack 
 
// ----------------------------------------------------------------------------- 
// Initialize/open our palette 
// ----------------------------------------------------------------------------- 
 
static bool		Do_PaletteInit (void) 
{ 
	if (myDialID == 0 || !DGIsDialogOpen (myDialID)) 
		myDialID = DGModelessInit (ACAPI_GetOwnResModule (), 32400, ACAPI_GetOwnResModule (), CntlDlgCallBack, NULL, 1); 
 
	return myDialID != 0; 
}		// Do_PaletteInit&lt;/PRE&gt; &lt;BR /&gt;
 &lt;BR /&gt;
Regards, &lt;BR /&gt;
Tibor</description>
      <pubDate>Thu, 13 Nov 2014 21:59:06 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Modeless-or-Palette-Dialog-help/m-p/215902#M5362</guid>
      <dc:creator>Tibor Lorantfy</dc:creator>
      <dc:date>2014-11-13T21:59:06Z</dc:date>
    </item>
  </channel>
</rss>

