<?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: C++ TabControl multi tab issue in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/C-TabControl-multi-tab-issue/m-p/289303#M4855</link>
    <description>&lt;BLOCKQUOTE&gt;ggiloyan wrote:&lt;BR /&gt;So please explain me why my code works only for first tab ?&lt;BR /&gt;
And why I need Observer also for Dialog ?&lt;/BLOCKQUOTE&gt;
Observers handle the user interface changes. So if the user selects an another tab, then the observer must handle it and run the required updates.&lt;BR /&gt;
In your case I think one of the required updated didn't run and that's why you should implement an observer for your dialog class, and attach the observer to the dialog.</description>
    <pubDate>Thu, 06 Aug 2015 13:50:24 GMT</pubDate>
    <dc:creator>Tibor Lorantfy</dc:creator>
    <dc:date>2015-08-06T13:50:24Z</dc:date>
    <item>
      <title>C++ TabControl multi tab issue</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/C-TabControl-multi-tab-issue/m-p/289298#M4850</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;I have a TabControl (NormalTab) which has two tab&lt;BR /&gt;&lt;BR /&gt;I have five classes to implement my TabControl&lt;BR /&gt;There is one main dialog class and two class for each tab.&lt;BR /&gt;&lt;BR /&gt;My dialog opens without any problem. First tab events fires without any problem. The only problem is that second tab events (ButtonClicked) do not fire and I can not change any control text in second tab.&lt;BR /&gt;&lt;BR /&gt;Here is my whole code.&lt;BR /&gt;&lt;BR /&gt;resource file
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;
'GDLG'	32511	Modal 	0	0	 444  174  "Upload IFC" {
/* [  1] */ NormalTab			  0   0  428 148
								  32512 NoIcon "New" 
								  32513 NoIcon "Existing"

}

'DLGH'  32511  DLG_32511_Upload_IFC {
1	""							uploadTabControl
}

'GDLG'  32512    TabPage  0    0 428 134  "" {
/* [  1] */  LeftText           13   23   84   13  LargePlain		"Model file name:"
/* [  2] */  TextEdit			104  18   293  20  LargePlain		256
/* [  3] */  Separator		    13   53   385  1
/* [  4] */  Button				241  68	  75   23  LargePlain		"Cancel"
/* [  5] */  Button				322  68	  75   23  LargePlain		"Upload" 
}

'DLGH'  32512  TabPage_32512 {
1	""							lblModelName_New
2	""							txtModelName
3	""							seperator_0
4	""							btnCancel
5	""							btnUpload
}

'GDLG'  32513    TabPage  0    0 428 134  "" {
/* [  1] */  LeftText           13   23   84   13  LargePlain		"Model file name:"
/* [  2] */  PopupControl		104  18   293  20  144 0
/* [  3] */  Separator		    13   53   385  1
/* [  4] */  Button				241  68	  75   23  LargePlain		"Cancel"
/* [  5] */  Button				322  68	  75   23  LargePlain		"Upload" 
}

'DLGH'  32513  TabPage_32513 {
1	""							lblModelName_Existing
2	""							comboModelName
3   ""							seperator_2
4	""							btnCancel
5	""							btnUpload
}

&lt;/PRE&gt;
.h file&lt;BR /&gt;
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;class ExportDialog : public DG::ModalDialog
{

	friend class NewTabControl;
	friend class NewTabControlObserver;

	friend class EditTabControl;
	friend class EditTabControlObserver;

private:

	enum ui  {
	
		id = 32511,
		normalTabID = 1
	};

	DG::NormalTab   m_normalTab;
	
	NewTabControl		*m_newTabControl;	
	NewTabControlObserver  *m_newTabObserver;
	
	EditTabControl		*m_editTabControl;
	EditTabControlObserver	*m_editTabObserver;

public:
	ExportDialog();
	~ExportDialog();

private:
	ExportDialog(const ExportDialog&amp;amp;);
	const	ExportDialog&amp;amp; operator=(const ExportDialog&amp;amp;); //Disabled

};

// ----------------------------------------------- New tabe class---------------------------------------------------- 

class NewTabControl : public DG::TabPage 
{
	friend class NewTabControlObserver;

private:
	
	enum ui {
		
		TabID = 32512,
		lblModelNameID = 1,
		txtModelNameID = 2,
		seperator0ID = 3,
		btnCancelID = 4,
		btnUploadID = 5
	};

	DG::TextEdit	m_txtModelName;
	DG::Button		m_btnCancel;
	DG::Button		m_btnSave;

public:
	NewTabControl( const DG::TabControl&amp;amp; tabControl, short tabItem );
	~NewTabControl( void );
};

class EditTabControl : public DG::TabPage 
{
	friend class EditTabControlObserver;

private:
	
	enum ui {
		
		TabID = 32513,
		comboModel = 2,
		btnCancelID = 4,
		btnUploadID = 5
	};

	DG::PopUp		m_comboModel;
	DG::Button		m_btnCancel;
	DG::Button		m_btnSave;

public:
	EditTabControl( const DG::TabControl&amp;amp; tabControl, short tabItem );
	~EditTabControl( void );
};


// ----------------------------------------------- TabControlObserver ----------------------------------------------- 

class NewTabControlObserver :  public DG::PanelObserver, 
               public DG::NormalTabObserver, 
               public DG::ButtonItemObserver, 
               public DG::CompoundItemObserver 
{ 
private: 
	NewTabControl		*m_newTabControl; 
	ExportDialog		&amp;amp;mainDialog;

protected: 
   // DG::PanelObserver 
   virtual void   PanelOpened (const DG::PanelOpenEvent&amp;amp; ev) override;
   // DG::ButtonItemObserver 
   virtual void   ButtonClicked (const DG::ButtonClickEvent&amp;amp; ev) override; 

public: 
   explicit      NewTabControlObserver (NewTabControl* newTabControl, ExportDialog &amp;amp;exportDialog); 
   ~NewTabControlObserver (); 
}; 

// ----------------------------------------------- EditControlObserver -----------------------------------------------

class EditTabControlObserver : public DG::PanelObserver, 
               public DG::NormalTabObserver, 
               public DG::ButtonItemObserver, 
               public DG::CompoundItemObserver 
{ 
private: 
	EditTabControl		*m_EditTabControl; 
	ExportDialog		&amp;amp;mainDialog;

protected: 
   // DG::PanelObserver 
   virtual void   PanelOpened (const DG::PanelOpenEvent&amp;amp; ev) override;

   // DG::ButtonItemObserver 
   virtual void   ButtonClicked (const DG::ButtonClickEvent&amp;amp; ev) override; 

public: 
   explicit      EditTabControlObserver (EditTabControl* editTabControl, ExportDialog &amp;amp;exportDialog); 
   ~EditTabControlObserver (); 
}; 
&lt;/PRE&gt;
.cpp&lt;BR /&gt;
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;
ExportDialog::ExportDialog() : 
ModalDialog (ACAPI_GetOwnResModule (), ui::id, InvalidResModule),
	m_normalTab(GetReference (), ui::normalTabID),

	m_newTabControl(new NewTabControl(m_normalTab, ui::normalTabID)),
	m_newTabObserver(new NewTabControlObserver(m_newTabControl, *this)),

	m_editTabControl(new EditTabControl(m_normalTab, ui::normalTabID)),
	m_editTabObserver(new EditTabControlObserver(m_editTabControl, *this))
{

}

ExportDialog::~ExportDialog()
{
	delete m_newTabObserver;
	delete m_newTabControl;
}

//------------------------------ NewTabClass -------------------------------- 

NewTabControl::NewTabControl (const DG::TabControl&amp;amp; tabControl, short tabItem): 
		DG::TabPage         (tabControl, tabItem, ACAPI_GetOwnResModule(), ui::TabID, ACAPI_GetOwnResModule ()), 
		m_txtModelName      (GetReference (), ui::txtModelNameID),
		m_btnCancel(GetReference (), ui::btnCancelID),
		m_btnSave(GetReference (), ui::btnUploadID)
{ 
 
}
  
NewTabControl::~NewTabControl () 
{ 
	
} 


//-----------------------------------------------------------------EditTabClass----------------------------------------------------------
 
EditTabControl::EditTabControl (const DG::TabControl&amp;amp; tabControl, short tabItem): 
DG::TabPage         (tabControl, tabItem, ACAPI_GetOwnResModule(), ui::TabID, ACAPI_GetOwnResModule ()), 
		m_comboModel      (GetReference (), ui::comboModel),
		m_btnCancel(GetReference (), ui::btnCancelID),
		m_btnSave(GetReference (), ui::btnUploadID)
{ 
 
	this-&amp;gt;m_btnCancel.SetText("ascaca");
}
  
EditTabControl::~EditTabControl () 
{ 
} 


//-------------------------- Class TabControlObserver ----------------------- 

NewTabControlObserver::NewTabControlObserver (NewTabControl* newTabControl, ExportDialog &amp;amp;exportDialog): 
   m_newTabControl (newTabControl),
   mainDialog(exportDialog)
{ 
   m_newTabControl-&amp;gt;Attach (*this); 
   AttachToAllItems (*m_newTabControl); 
} 


NewTabControlObserver::~NewTabControlObserver () 
{ 
   m_newTabControl-&amp;gt;Detach (*this); 
   DetachFromAllItems (*m_newTabControl); 
} 


void NewTabControlObserver::PanelOpened (const DG::PanelOpenEvent&amp;amp; ev) 
{ 
  
} 
 
void NewTabControlObserver::ButtonClicked (const DG::ButtonClickEvent&amp;amp; ev) 
{ 
   // Close dialog with acceptance 
	
	if (ev.GetSource () == &amp;amp;m_newTabControl-&amp;gt;m_btnCancel) { 
	  
		mainDialog.PostCloseRequest(DG::ModalDialog::Accept);

    }  
	else if ( ev.GetSource() == &amp;amp;m_newTabControl-&amp;gt;m_btnSave ) 
	{
		
		
	}
} 

//---------------------------------------------------------------------------------------------------------------------------------------------------------

//-------------------------- Class TabControlObserver ----------------------- 

EditTabControlObserver::EditTabControlObserver (EditTabControl* editTabControl, ExportDialog &amp;amp;exportDialog): 
   m_EditTabControl (editTabControl),
   mainDialog(exportDialog)
{ 
   m_EditTabControl-&amp;gt;Attach (*this); 
   AttachToAllItems (*m_EditTabControl); 
} 


EditTabControlObserver::~EditTabControlObserver () 
{ 
   m_EditTabControl-&amp;gt;Detach (*this); 
   DetachFromAllItems (*m_EditTabControl); 
} 


void EditTabControlObserver::PanelOpened (const DG::PanelOpenEvent&amp;amp; ev) 
{ 
 
} 
 
 
void EditTabControlObserver::ButtonClicked (const DG::ButtonClickEvent&amp;amp; ev) 
{ 
   // Close dialog with acceptance 
	
	if (ev.GetSource () == &amp;amp;m_EditTabControl-&amp;gt;m_btnCancel) { 
	  
		mainDialog.PostCloseRequest(DG::ModalDialog::Accept);

    }  
	else if ( ev.GetSource() == &amp;amp;m_EditTabControl-&amp;gt;m_btnSave ) 
	{
		
		
	}
} 

&lt;/PRE&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 13 Jul 2023 13:43:39 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/C-TabControl-multi-tab-issue/m-p/289298#M4850</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-07-13T13:43:39Z</dc:date>
    </item>
    <item>
      <title>Re: C++ TabControl multi tab issue</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/C-TabControl-multi-tab-issue/m-p/289299#M4851</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
There could be more bugs in your code, but the first I noticed is the following:&lt;BR /&gt;
You should have an observer class for your modaldialog also (ExportDialogObserver), so 2 class for each.&lt;BR /&gt;
And the modaldialog's observer should be inherited from DG::PanelObserver, DG::NormalTabObserver and DG::CompoundItemObserver.&lt;BR /&gt;
&lt;BR /&gt;
It's a mistake in your code that your tabpages' observers inherited from DG::NormalTabObserver, however they don't have any NormalTab, so please delete that inheritance.&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Tibor</description>
      <pubDate>Thu, 06 Aug 2015 07:15:20 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/C-TabControl-multi-tab-issue/m-p/289299#M4851</guid>
      <dc:creator>Tibor Lorantfy</dc:creator>
      <dc:date>2015-08-06T07:15:20Z</dc:date>
    </item>
    <item>
      <title>Re: C++ TabControl multi tab issue</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/C-TabControl-multi-tab-issue/m-p/289300#M4852</link>
      <description>&lt;BLOCKQUOTE&gt;Tibor wrote:&lt;BR /&gt;Hi,&lt;BR /&gt;
&lt;BR /&gt;
There could be more bugs in your code, but the first I noticed is the following:&lt;BR /&gt;
You should have an observer class for your modaldialog also (ExportDialogObserver), so 2 class for each.&lt;BR /&gt;
And the modaldialog's observer should be inherited from DG::PanelObserver, DG::NormalTabObserver and DG::CompoundItemObserver.&lt;BR /&gt;
&lt;BR /&gt;
It's a mistake in your code that your tabpages' observers inherited from DG::NormalTabObserver, however they don't have any NormalTab, so please delete that inheritance.&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Tibor&lt;/BLOCKQUOTE&gt;

&lt;BR /&gt;
Than you for the response.&lt;BR /&gt;
&lt;BR /&gt;
What concern to tabpage's observers I removed the DG::NormalTabObserver.&lt;BR /&gt;
&lt;BR /&gt;
The strange thing is that first tab functionality working fine. The only problem is second tab.&lt;BR /&gt;
&lt;BR /&gt;
What concern ModelDialog why I should have an observer class ?&lt;BR /&gt;
&lt;BR /&gt;
Some times age you gave me this example where the main dialog has no observer&lt;BR /&gt;
&lt;BR /&gt;
&lt;A href="http://archicad-talk.graphisoft.com/viewtopic.php?t=48241" target="_blank"&gt;&lt;/A&gt;&lt;S&gt;&lt;A href="http://archicad-talk.graphisoft.com/viewtopic.php?t=48241" target="_blank"&gt;&lt;/A&gt;&lt;A href="&amp;lt;/s&amp;gt;&amp;lt;LINK_TEXT text=&amp;quot;http://archicad-talk.graphisoft.com/vie ... hp?t=48241&amp;quot;&amp;gt;http://archicad-talk.graphisoft.com/viewtopic.php?t=48241&amp;lt;/LINK_TEXT&amp;gt;&amp;lt;e&amp;gt;"&gt;&lt;/A&gt;&lt;/S&gt;&lt;LINK_TEXT text="http://archicad-talk.graphisoft.com/vie ... hp?t=48241"&gt;http://archicad-talk.graphisoft.com/viewtopic.php?t=48241&lt;/LINK_TEXT&gt;&lt;E&gt;&lt;/E&gt;</description>
      <pubDate>Thu, 06 Aug 2015 11:06:24 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/C-TabControl-multi-tab-issue/m-p/289300#M4852</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-08-06T11:06:24Z</dc:date>
    </item>
    <item>
      <title>Re: C++ TabControl multi tab issue</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/C-TabControl-multi-tab-issue/m-p/289301#M4853</link>
      <description>&lt;BLOCKQUOTE&gt;ggiloyan wrote:&lt;BR /&gt;Some times age you gave me this example where the main dialog has no observer&lt;BR /&gt;
&lt;BR /&gt;
&lt;A href="http://archicad-talk.graphisoft.com/viewtopic.php?t=48241" target="_blank"&gt;&lt;/A&gt;&lt;S&gt;&lt;A href="http://archicad-talk.graphisoft.com/viewtopic.php?t=48241" target="_blank"&gt;&lt;/A&gt;&lt;A href="&amp;lt;/s&amp;gt;&amp;lt;LINK_TEXT text=&amp;quot;http://archicad-talk.graphisoft.com/vie ... hp?t=48241&amp;quot;&amp;gt;http://archicad-talk.graphisoft.com/viewtopic.php?t=48241&amp;lt;/LINK_TEXT&amp;gt;&amp;lt;e&amp;gt;"&gt;&lt;/A&gt;&lt;/S&gt;&lt;LINK_TEXT text="http://archicad-talk.graphisoft.com/vie ... hp?t=48241"&gt;http://archicad-talk.graphisoft.com/viewtopic.php?t=48241&lt;/LINK_TEXT&gt;&lt;E&gt;&lt;/E&gt;&lt;/BLOCKQUOTE&gt;
That is not true.&lt;BR /&gt;
In that code TabControlDialog has an observer class named TabControlObserver.</description>
      <pubDate>Thu, 06 Aug 2015 11:14:27 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/C-TabControl-multi-tab-issue/m-p/289301#M4853</guid>
      <dc:creator>Tibor Lorantfy</dc:creator>
      <dc:date>2015-08-06T11:14:27Z</dc:date>
    </item>
    <item>
      <title>Re: C++ TabControl multi tab issue</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/C-TabControl-multi-tab-issue/m-p/289302#M4854</link>
      <description>I'm confused.&lt;BR /&gt;
&lt;BR /&gt;
So please explain me why my code works only for first tab ?&lt;BR /&gt;
And why I need Observer also for Dialog ?</description>
      <pubDate>Thu, 06 Aug 2015 12:48:24 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/C-TabControl-multi-tab-issue/m-p/289302#M4854</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-08-06T12:48:24Z</dc:date>
    </item>
    <item>
      <title>Re: C++ TabControl multi tab issue</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/C-TabControl-multi-tab-issue/m-p/289303#M4855</link>
      <description>&lt;BLOCKQUOTE&gt;ggiloyan wrote:&lt;BR /&gt;So please explain me why my code works only for first tab ?&lt;BR /&gt;
And why I need Observer also for Dialog ?&lt;/BLOCKQUOTE&gt;
Observers handle the user interface changes. So if the user selects an another tab, then the observer must handle it and run the required updates.&lt;BR /&gt;
In your case I think one of the required updated didn't run and that's why you should implement an observer for your dialog class, and attach the observer to the dialog.</description>
      <pubDate>Thu, 06 Aug 2015 13:50:24 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/C-TabControl-multi-tab-issue/m-p/289303#M4855</guid>
      <dc:creator>Tibor Lorantfy</dc:creator>
      <dc:date>2015-08-06T13:50:24Z</dc:date>
    </item>
    <item>
      <title>Re: C++ TabControl multi tab issue</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/C-TabControl-multi-tab-issue/m-p/289304#M4856</link>
      <description>I added also Dialog's observer but the result is the same&lt;BR /&gt;
&lt;BR /&gt;
The strange thing is that my second tab constructor working and in constructor I wrote this this-&amp;gt;m_btnCancel.SetText("ascaca"); which does not change the button name. &lt;BR /&gt;
&lt;BR /&gt;
Here is the new dialog's observer class&lt;BR /&gt;

&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;
class TabControlObserver:   public DG::PanelObserver, 
               public DG::NormalTabObserver, 
               public DG::ButtonItemObserver, 
               public DG::CompoundItemObserver 
{ 
private: 
   ExportDialog*      mDialog; 

protected: 
   // DG::PanelObserver 
   virtual void   PanelOpened (const DG::PanelOpenEvent&amp;amp; ev) override; 

   // DG::ButtonItemObserver 
   virtual void   ButtonClicked (const DG::ButtonClickEvent&amp;amp; ev) override; 

public: 
   explicit      TabControlObserver (ExportDialog* testDialog); 
   ~TabControlObserver (); 
}; 

&lt;/PRE&gt;

.cpp&lt;BR /&gt;

&lt;PRE&gt;TabControlObserver::TabControlObserver (ExportDialog* testDialog): 
   mDialog (testDialog) 
{ 
   mDialog-&amp;gt;Attach (*this); 
   AttachToAllItems (*mDialog); 
} 


TabControlObserver::~TabControlObserver () 
{ 
   mDialog-&amp;gt;Detach (*this); 
   DetachFromAllItems (*mDialog); 
} 


void TabControlObserver::PanelOpened (const DG::PanelOpenEvent&amp;amp; /*ev*/) 
{ 
   mDialog-&amp;gt;SetClientSize (mDialog-&amp;gt;GetOriginalClientWidth (), mDialog-&amp;gt;GetOriginalClientHeight ()); 
} 


void TabControlObserver::ButtonClicked (const DG::ButtonClickEvent&amp;amp; ev) 
{ 
   
} &lt;/PRE&gt;

&lt;BR /&gt;
And I'm calling the dialog by this way&lt;BR /&gt;

&lt;PRE&gt;ExportDialog      dialog (ACAPI_GetOwnResModule (), 32511); 
   
	if (DBERROR (dialog.GetId () == 0)) { 
		return; 
	} 
  
	TabControlObserver      observer (&amp;amp;dialog); 
	dialog.Invoke (); 
	return;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Aug 2015 14:53:25 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/C-TabControl-multi-tab-issue/m-p/289304#M4856</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-08-06T14:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: C++ TabControl multi tab issue</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/C-TabControl-multi-tab-issue/m-p/289305#M4857</link>
      <description>Hi.&lt;BR /&gt;
I have the same problem. &lt;BR /&gt;
What is the solution to this problem?&lt;BR /&gt;
Thanks.</description>
      <pubDate>Thu, 07 Nov 2019 11:40:31 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/C-TabControl-multi-tab-issue/m-p/289305#M4857</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-11-07T11:40:31Z</dc:date>
    </item>
  </channel>
</rss>

