<?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: How to make the basic modal dialog using resource? in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-make-the-basic-modal-dialog-using-resource/m-p/258324#M2951</link>
    <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I would recommend you to read our blog post: &lt;A href="http://archicadapi.graphisoft.com/hello-world-part-2-dialog-with-text-svg-icon-and-button" target="_blank"&gt;&lt;/A&gt;&lt;S&gt;&lt;A href="http://archicadapi.graphisoft.com/hello-world-part-2-dialog-with-text-svg-icon-and-button" target="_blank"&gt;&lt;/A&gt;&lt;A href="&amp;lt;/s&amp;gt;&amp;lt;LINK_TEXT text=&amp;quot;http://archicadapi.graphisoft.com/hello ... and-button&amp;quot;&amp;gt;http://archicadapi.graphisoft.com/hello-world-part-2-dialog-with-text-svg-icon-and-button&amp;lt;/LINK_TEXT&amp;gt;&amp;lt;e&amp;gt;"&gt;&lt;/A&gt;&lt;/S&gt;&lt;LINK_TEXT text="http://archicadapi.graphisoft.com/hello ... and-button"&gt;http://archicadapi.graphisoft.com/hello-world-part-2-dialog-with-text-svg-icon-and-button&lt;/LINK_TEXT&gt;&lt;E&gt;&lt;/E&gt;&lt;BR /&gt;
&lt;BR /&gt;
It demonstrates how to create a basic dialog using GRC resource.&lt;BR /&gt;
I summarize the most important parts for you:&lt;BR /&gt;
&lt;BR /&gt;
You can define the look of your dialog in your GRC resource file. If your GRC looks like this:
&lt;PRE&gt;'GDLG'  32500  Modal	 40   40  300  130  "Hello World Example Dialog" {
/* [  1] */ Button	145  102  150   21	LargePlain  "Close"
/* [  2] */ LeftText	145   55  150   40	LargePlain  "Hello World"
/* [  3] */ Icon	  5    5  120  120	32500
}

'DLGH'  32500  DLG_32500 {
1	"Close Button"		Button_0
2	"Hello World Text"	LeftText_0
3	"Earth Icon"		IconItem_0
}&lt;/PRE&gt;

Then you should create a C++ class for your dialog inherited from the DG::ModalDialog class.
&lt;PRE&gt;#include	"DGModule.hpp"

class HelloWorldDialog : public DG::ModalDialog,
			 public DG::ButtonItemObserver,
			 public DG::CompoundItemObserver
{
protected:
	enum Controls {
		ButtonID	= 1,
		LeftTextID	= 2,
		IconItemID	= 3
	};

	DG::Button	closeButton;
	DG::LeftText	helloWorldText;
	DG::IconItem	earthIcon;

	virtual void	ButtonClicked	(const DG::ButtonClickEvent&amp;amp; ev) override;

public:
	HelloWorldDialog ();
	~HelloWorldDialog ();
};

HelloWorldDialog::HelloWorldDialog () :
	DG::ModalDialog (ACAPI_GetOwnResModule (), 32500, ACAPI_GetOwnResModule ()),
	closeButton	(GetReference (), ButtonID),
	helloWorldText	(GetReference (), LeftTextID),
	earthIcon	(GetReference (), IconItemID)
{
	AttachToAllItems (*this);
}

HelloWorldDialog::~HelloWorldDialog ()
{
}

void HelloWorldDialog::ButtonClicked (const DG::ButtonClickEvent&amp;amp; ev)
{
	if (ev.GetSource () == &amp;amp;closeButton)
		PostCloseRequest (Accept);
}&lt;/PRE&gt;

And finally you can show your dialog by creating an instance from your class and calling its Invoke method:
&lt;PRE&gt;static void	ShowDialog ()
{
	HelloWorldDialog dialog;
	dialog.Invoke ();
}&lt;/PRE&gt;</description>
    <pubDate>Wed, 08 Jul 2020 15:08:03 GMT</pubDate>
    <dc:creator>Tibor Lorantfy</dc:creator>
    <dc:date>2020-07-08T15:08:03Z</dc:date>
    <item>
      <title>How to make the basic modal dialog using resource?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-make-the-basic-modal-dialog-using-resource/m-p/258323#M2950</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Dear developers,&lt;BR /&gt;&lt;BR /&gt;I saw the DG_Test.&lt;BR /&gt;But I didn't understand the codes.&lt;BR /&gt;I wish to know how to make the basic modal dialog using resource.&lt;BR /&gt;&lt;BR /&gt;Following is my code. This is incomplete code.&lt;BR /&gt;
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;...

static short DGCALLBACK place_Euroform_Handler (short			message,
												short			dialogID,
												short			item,
												DGUserData		userData,
												DGMessageData	msgData)
{
	return 0;
}		// Callback function for DG

...

GSErrCode __ACENV_CALL	CommandHandler (const API_MenuParams *menuParams)
{
	GSErrCode	err = NoError;
	bool		isOK;
	DGUserData	userData;

	isOK = DGModalDialog (ACAPI_GetOwnResModule (), 32510, ACAPI_GetOwnResModule (), place_Euroform_Handler, userData == DG_OK);

	return err;
}

...
&lt;/PRE&gt;
Following is .grc file.
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;...

#include "DGDefs.h"
#include "DGWinDefs.h"

/* ------------------------------------------------------------ place Euroform */

'GDLG'	32510	Modal	40	40	300	400	"" {
/* [  1] */ Button				170  350   70   20  LargePlain		"OK"
/* [  2] */ Button				100  350   70   20  LargePlain		"Cancel"
/* [  3] */ CenterText			  8    4  250   12  SmallPlain		"Sample text"
}

'DLGH'	32510	DLG_32510 {
1	"OK Button"			Button_0
2	"Cancel Button"		Button_1
3	"Text"				CenterText_0
}
&lt;/PRE&gt;
&lt;BR /&gt;&lt;BR /&gt;Environment&lt;BR /&gt;- Windows 7&lt;BR /&gt;- Visual Studio 2010&lt;BR /&gt;- API v19 and ArchiCAD 19&lt;/DIV&gt;</description>
      <pubDate>Wed, 15 Sep 2021 09:58:37 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-to-make-the-basic-modal-dialog-using-resource/m-p/258323#M2950</guid>
      <dc:creator>Soonbum Jeong</dc:creator>
      <dc:date>2021-09-15T09:58:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to make the basic modal dialog using resource?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-make-the-basic-modal-dialog-using-resource/m-p/258324#M2951</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I would recommend you to read our blog post: &lt;A href="http://archicadapi.graphisoft.com/hello-world-part-2-dialog-with-text-svg-icon-and-button" target="_blank"&gt;&lt;/A&gt;&lt;S&gt;&lt;A href="http://archicadapi.graphisoft.com/hello-world-part-2-dialog-with-text-svg-icon-and-button" target="_blank"&gt;&lt;/A&gt;&lt;A href="&amp;lt;/s&amp;gt;&amp;lt;LINK_TEXT text=&amp;quot;http://archicadapi.graphisoft.com/hello ... and-button&amp;quot;&amp;gt;http://archicadapi.graphisoft.com/hello-world-part-2-dialog-with-text-svg-icon-and-button&amp;lt;/LINK_TEXT&amp;gt;&amp;lt;e&amp;gt;"&gt;&lt;/A&gt;&lt;/S&gt;&lt;LINK_TEXT text="http://archicadapi.graphisoft.com/hello ... and-button"&gt;http://archicadapi.graphisoft.com/hello-world-part-2-dialog-with-text-svg-icon-and-button&lt;/LINK_TEXT&gt;&lt;E&gt;&lt;/E&gt;&lt;BR /&gt;
&lt;BR /&gt;
It demonstrates how to create a basic dialog using GRC resource.&lt;BR /&gt;
I summarize the most important parts for you:&lt;BR /&gt;
&lt;BR /&gt;
You can define the look of your dialog in your GRC resource file. If your GRC looks like this:
&lt;PRE&gt;'GDLG'  32500  Modal	 40   40  300  130  "Hello World Example Dialog" {
/* [  1] */ Button	145  102  150   21	LargePlain  "Close"
/* [  2] */ LeftText	145   55  150   40	LargePlain  "Hello World"
/* [  3] */ Icon	  5    5  120  120	32500
}

'DLGH'  32500  DLG_32500 {
1	"Close Button"		Button_0
2	"Hello World Text"	LeftText_0
3	"Earth Icon"		IconItem_0
}&lt;/PRE&gt;

Then you should create a C++ class for your dialog inherited from the DG::ModalDialog class.
&lt;PRE&gt;#include	"DGModule.hpp"

class HelloWorldDialog : public DG::ModalDialog,
			 public DG::ButtonItemObserver,
			 public DG::CompoundItemObserver
{
protected:
	enum Controls {
		ButtonID	= 1,
		LeftTextID	= 2,
		IconItemID	= 3
	};

	DG::Button	closeButton;
	DG::LeftText	helloWorldText;
	DG::IconItem	earthIcon;

	virtual void	ButtonClicked	(const DG::ButtonClickEvent&amp;amp; ev) override;

public:
	HelloWorldDialog ();
	~HelloWorldDialog ();
};

HelloWorldDialog::HelloWorldDialog () :
	DG::ModalDialog (ACAPI_GetOwnResModule (), 32500, ACAPI_GetOwnResModule ()),
	closeButton	(GetReference (), ButtonID),
	helloWorldText	(GetReference (), LeftTextID),
	earthIcon	(GetReference (), IconItemID)
{
	AttachToAllItems (*this);
}

HelloWorldDialog::~HelloWorldDialog ()
{
}

void HelloWorldDialog::ButtonClicked (const DG::ButtonClickEvent&amp;amp; ev)
{
	if (ev.GetSource () == &amp;amp;closeButton)
		PostCloseRequest (Accept);
}&lt;/PRE&gt;

And finally you can show your dialog by creating an instance from your class and calling its Invoke method:
&lt;PRE&gt;static void	ShowDialog ()
{
	HelloWorldDialog dialog;
	dialog.Invoke ();
}&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Jul 2020 15:08:03 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-to-make-the-basic-modal-dialog-using-resource/m-p/258324#M2951</guid>
      <dc:creator>Tibor Lorantfy</dc:creator>
      <dc:date>2020-07-08T15:08:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to make the basic modal dialog using resource?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-make-the-basic-modal-dialog-using-resource/m-p/258325#M2952</link>
      <description>Thank you, Tibor Lorántfy!&lt;BR /&gt;
You gave me the best solution!&lt;BR /&gt;
 &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_biggrin.gif" style="display : inline;" /&gt;</description>
      <pubDate>Thu, 09 Jul 2020 00:14:16 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-to-make-the-basic-modal-dialog-using-resource/m-p/258325#M2952</guid>
      <dc:creator>Soonbum Jeong</dc:creator>
      <dc:date>2020-07-09T00:14:16Z</dc:date>
    </item>
  </channel>
</rss>

