2023-04-27 11:47 PM - edited 2023-04-28 01:31 AM
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
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
Solved! Go to Solution.
2023-04-28 12:06 PM
To be able to use AttachToAllItems function your class needs to inherit from DG::CompoundItemObserver
2023-04-28 12:06 PM
To be able to use AttachToAllItems function your class needs to inherit from DG::CompoundItemObserver
2023-04-28 09:36 PM
Brilliant! Thanks for the response that was right on target.
- Chris