cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 
2024 Technology Preview Program

2024 Technology Preview Program:
Master powerful new features and shape the latest BIM-enabled innovations

Archicad C++ API
About Archicad add-on development using the C++ API.
SOLVED!

identifier AttachToAllItems is undefined

MudratDetector
Enthusiast

Hey all,

 

[AC24, VS 2017]


I am stumped on this.  I have successfully used dialogs in other Add_Ons.  I am using a working, previous project as a go-by for this new one.  Maybe that's my problem, but it is not clear to me how slight differences would impact.

 

So far, I have created a blank dialog with only an 'OK' button to test my proof of concept.  It will eventually be employed to alert the users if they should open a .bpn file.

in the .grc file

 

 

 

#include "JHP_AutoLoadResIDs.hpp"

'GDLG' 32500  Modal	0	0  1000  1000	"JHP:  ERROR - Do not open .bpn file" {
/* [  1] */ Button	400  300   70   43		LargePlain	"OK"
}

'DLGH'  32500  DLG_32500_JHP_AUTOLOAD {
1	"JHP_OK"	Button_0
}

 

 

 



in the .hpp file

 

 

 

#pragma once

#ifndef JHP_AUTOLOAD_DIALOG_HPP
#define JHP_AUTOLOAD_DIALOG_HPP

#include	"DGModule.hpp"

class JHP_AutoLoad_Dialog :	public DG::ModalDialog,
				public DG::ButtonItemObserver
{
protected:
	enum Controls {
		OkID = 1
	};

	DG::Button OK_Button;
	virtual void ButtonClicked(const DG::ButtonClickEvent& ev) override;
public:
	JHP_AutoLoad_Dialog();
	~JHP_AutoLoad_Dialog();
};

#endif JHP_AUTOLOAD_DIALOG_HPP

 

 

 

 

in the .cpp file

 

 

 

JHP_AutoLoad_Dialog::JHP_AutoLoad_Dialog() :
	DG::ModalDialog(ACAPI_GetOwnResModule(), 32500, ACAPI_GetOwnResModule()),
	OK_Button(GetReference(), OkID)
{
	AttachToAllItems(*this);
}

JHP_AutoLoad_Dialog::~JHP_AutoLoad_Dialog()
{
}

void JHP_AutoLoad_Dialog::ButtonClicked(const DG::ButtonClickEvent& ev)
{
	if (ev.GetSource() == &OK_Button)
	{
		PostCloseRequest(Cancel);
	}
}

 

 

 


It is here where the problem is

MudratDetector_0-1682630901388.png

 

I have tried to remedy this by:
- - making sure of necessary #include directives

- - rearranging chunks of code to influence definition

The main difference I see between this failed AttachToAllItems and the one that works in my go-by is that this Add-On does not provide a menu selection.  It only establishes

 

 

 

err = ACAPI_Notify_CatchProjectEvent(APINotify_Open, JHP_EventHandler);

 

 

 

in

 

 

 

// -----------------------------------------------------------------------------
// Initialize
//		called after the Add-On has been loaded into memory
// -----------------------------------------------------------------------------

GSErrCode __ACENV_CALL	Initialize (void)

 

 

 

 

This strategy of organization is working with calls to a typical ACAPI_WriteReport("message", true);


Could this placement of ACAPI_Notify_CatchProjectEvent in __ACENV_CALL Initialize be the cause?
Am I missing an #include?

New laptop - Am I missing something in my VS install/configuration?

Have I provided enough detail?

 

Thanks to all that look and many thanks to all that answer,

Chris

 

Chris Gilmer
Intel i9-12950HX CPU @ 2.30GHz, 16 cores
NVIDIA GeForce RTX 3080
48.0 GB RAM
Windows 10 Pro 64-bit
1 ACCEPTED SOLUTION

Accepted Solutions
Solution
julienK
Advocate

To be able to  use AttachToAllItems function your  class needs  to inherit from  DG::CompoundItemObserver

View solution in original post

2 REPLIES 2
Solution
julienK
Advocate

To be able to  use AttachToAllItems function your  class needs  to inherit from  DG::CompoundItemObserver

MudratDetector
Enthusiast

Brilliant!  Thanks for the response that was right on target.
- Chris

MudratDetector_1-1682710582132.png

 


MudratDetector_0-1682710494394.png

 

Chris Gilmer
Intel i9-12950HX CPU @ 2.30GHz, 16 cores
NVIDIA GeForce RTX 3080
48.0 GB RAM
Windows 10 Pro 64-bit

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!