2022-09-27 12:10 AM - edited 2022-09-27 12:15 AM
Development in Archicad 24.
I have lost track of which button is which in my dialog. What I am about to describe is how I THINK it works.
First few buttons in the .grc file:
'GDLG' 32500 Modal 0 0 650 620 "JHP: UL Fire Assembly details" {
/* [ 1] */ Button 20 40 135 35 LargePlain "UL Assemblies - JHP"
/* [ ] */ Icon 20 100 135 35 JHP_UL_RED_B
/* [ 2] */ Button 179 40 135 35 LargePlain "GA Assemblies - JHP"
/* [ 3] */ Button 338 40 135 35 LargePlain "UL Assemblies - ONLINE"
/* [ 4] */ Button 497 40 135 35 LargePlain "GA Assemblies - ONLINE"
/* [ ] */ GroupBox 20 100 295 250 LargePlain Primary "Floor-Ceilings:"
/* [ 5] */ RadioButton 50 120 240 30 LargePlain 1 "A or B: Concrete or Cellular Steel Floor"
/* [ 6] */ RadioButton 50 150 240 30 LargePlain 1 "C: Glazing Systems"
The help resource for the same buttons:
'DLGH' 32500 DLG_32500_JHP_UL {
1 "JHP_UL_JHP" Button_0
2 "JHP_GA_JHP" Button_1
3 "JHP_UL_ONLINE" Button_2
4 "JHP_GA_ONLINE" Button_3
5 "JHP_UL_AB" RadioButton_0
6 "JHP_UL_C" RadioButton_1
The dialog class, in the .hpp file, for the same buttons:
class JHP_UL_Dialog : public DG::ModalDialog,
public DG::ButtonItemObserver,
public DG::CompoundItemObserver
{
protected:
enum Controls {
UL_JHPID = 1,
GA_JHPID = 2,
UL_ONLINEID = 3,
GA_ONLINEID = 4,
UL_ABID = 5,
UL_CID = 6,
DG::Button UL_JHP_Button;
DG::Button GA_JHP_Button;
DG::Button UL_ONLINE_Button;
DG::Button GA_ONLINE_Button;
DG::RadioButton UL_AB_Radio;
DG::RadioButton UL_C_Radio;
...
virtual void ButtonClicked(const DG::ButtonClickEvent& ev) override;
The definition of the dialog class, for the same buttons:
JHP_UL_Dialog::JHP_UL_Dialog() :
DG::ModalDialog(ACAPI_GetOwnResModule(), 32500, ACAPI_GetOwnResModule()),
UL_JHP_Button(GetReference(), UL_JHPID),
GA_JHP_Button(GetReference(), GA_JHPID),
UL_ONLINE_Button(GetReference(), UL_ONLINEID),
GA_ONLINE_Button(GetReference(), GA_ONLINEID),
UL_AB_Radio(GetReference(), UL_ABID),
UL_C_Radio(GetReference(), UL_CID),
void JHP_UL_Dialog::ButtonClicked(const DG::ButtonClickEvent& ev)
{
if (ev.GetSource() == &Cancel_Button)
PostCloseRequest(Accept);
}
And finally, my 'Cancel' button action:
void JHP_UL_Dialog::ButtonClicked(const DG::ButtonClickEvent& ev)
{
if (ev.GetSource() == &Cancel_Button)
PostCloseRequest(Accept);
}
Everything seems to be coordinated with regard to control names and ID numbers. But my 'Cancel' button [further down the list of 20+ other controls] does not cancel.
And if I hover over each control, I can see the name assigned to it.
For the first button, it is correct:
For the second, third, and fourth buttons, they are one off:
This offset continues throughout all the controls, until the very last one that is defined and the number of the offset has increased.
[Disregard 'OK04' - that is my way of confirming change when I build the new edits]
The complete dialog has buttons, radio buttons, a list box, and an image that will all be accessed, either by the user or programmatically.
I have reviewed the 'Hello World' dialog example and other examples included in the API Kit.
I believe I understand [but obviously not] the relationship between:
-- the IDs used in the 'DLGH' help resource [2 "JHP_GA_JHP" Button_1]
-- the enums in the dialog class [GA_JHPID = 2] and [DG::Button GA_JHP_Button;]
-- the assignment of the ID to the button in the definition of the dialog class [GA_JHP_Button(GetReference(), GA_JHPID)]
EDIT: After posting, I saw the line in the .grc file for my red icon [/* [ ] */ Icon 20 100 135 35 JHP_UL_RED_B] and will be investigating the alignment once that is removed.
Can someone point me in the right direction?
Loads of thanks,
Chris
2022-09-27 12:30 AM
Hi Chris!
I think your main issue is, that your item numbering is off. You cannot just leave out numbers for items. The numbering of items in the grc file e.g. "/* [ 1] */" are just comments and not instructions or specifications in the grc file! You could also leave out those comments. It's just a help to oneself to keep track of the item numbers. The items always get increasing number starting w/ 1, independent of you using them in the rest of your code or not. So the following snippet from your example is very misleading:
'GDLG' 32500 Modal 0 0 650 620 "JHP: UL Fire Assembly details" {
/* [ 1] */ Button 20 40 135 35 LargePlain "UL Assemblies - JHP"
/* [ ] */ Icon 20 100 135 35 JHP_UL_RED_B
/* [ 2] */ Button 179 40 135 35 LargePlain "GA Assemblies - JHP"
/* [ 3] */ Button 338 40 135 35 LargePlain "UL Assemblies - ONLINE"
/* [ 4] */ Button 497 40 135 35 LargePlain "GA Assemblies - ONLINE"
/* [ ] */ GroupBox 20 100 295 250 LargePlain Primary "Floor-Ceilings:"
/* [ 5] */ RadioButton 50 120 240 30 LargePlain 1 "A or B: Concrete or Cellular Steel Floor"
/* [ 6] */ RadioButton 50 150 240 30 LargePlain 1 "C: Glazing Systems"
I think a better way would be to have the following comments:
'GDLG' 32500 Modal 0 0 650 620 "JHP: UL Fire Assembly details" {
/* [ 1] */ Button 20 40 135 35 LargePlain "UL Assemblies - JHP"
/* [ 2] */ Icon 20 100 135 35 JHP_UL_RED_B
/* [ 3] */ Button 179 40 135 35 LargePlain "GA Assemblies - JHP"
/* [ 4] */ Button 338 40 135 35 LargePlain "UL Assemblies - ONLINE"
/* [ 5] */ Button 497 40 135 35 LargePlain "GA Assemblies - ONLINE"
/* [ 6] */ GroupBox 20 100 295 250 LargePlain Primary "Floor-Ceilings:"
/* [ 7] */ RadioButton 50 120 240 30 LargePlain 1 "A or B: Concrete or Cellular Steel Floor"
/* [ 8] */ RadioButton 50 150 240 30 LargePlain 1 "C: Glazing Systems"
and then adapt the numbers in your files accordingly.
This also explains why the help is off by one in the for buttons 2-4 (in your old numbering) and why later the offset increases since you leave out an additional item (the groupBox "Floor-Ceilings:".
Best,
Bernd
2022-09-27 12:38 AM
Hi Chris,
I'm trying again to answer this. I think my last reply is lost. (Mentioning this just in case there are 2 answers from me popping up).
Your main issue is, that the item numbering is wrong. The numbering in the .grc file, e.g. "/* [ 1] */", are just comments and do not specify anything. The real numbering is just the order of appearance in the list. So there's no option to skip items in this numbering. I adapted your corresponding snippet with "more correct" comments:
'GDLG' 32500 Modal 0 0 650 620 "JHP: UL Fire Assembly details" {
/* [ 1] */ Button 20 40 135 35 LargePlain "UL Assemblies - JHP"
/* [ 2] */ Icon 20 100 135 35 JHP_UL_RED_B
/* [ 3] */ Button 179 40 135 35 LargePlain "GA Assemblies - JHP"
/* [ 4] */ Button 338 40 135 35 LargePlain "UL Assemblies - ONLINE"
/* [ 5] */ Button 497 40 135 35 LargePlain "GA Assemblies - ONLINE"
/* [ 6] */ GroupBox 20 100 295 250 LargePlain Primary "Floor-Ceilings:"
/* [ 7] */ RadioButton 50 120 240 30 LargePlain 1 "A or B: Concrete or Cellular Steel Floor"
/* [ 8] */ RadioButton 50 150 240 30 LargePlain 1 "C: Glazing Systems"
That also explains why the dialog help seems to be off by 1 at first and then off by 2 buttons. So you'd have to adapt all your numbering to the above snippet. You still can skip items in your code files but you have to use the correct numbering. E.g. this should work:
class JHP_UL_Dialog : public DG::ModalDialog,
public DG::ButtonItemObserver,
public DG::CompoundItemObserver
{
protected:
enum Controls {
UL_JHPID = 1,
GA_JHPID = 3,
UL_ONLINEID = 4,
GA_ONLINEID = 5,
UL_ABID = 7,
UL_CID = 8,
Best,
Bernd
2022-09-27 01:20 AM - edited 2022-09-27 01:21 AM
The 'yet to be determined' red icon was part of it. Failing to ID GroupBox controls around my radio buttons was another part.
I have no longer lost track of which button is which!
Chris
2022-09-27 04:46 AM
Sorry, your posts got auto detected as spam, probably due to the content.
I have now released them.
Barry.
2022-09-27 04:49 PM - edited 2022-09-27 04:50 PM
Bernd,
This is what I discovered shortly after the initial post. I removed unused controls and renumbered all remaining controls, even ones I had no intention of accessing or modifying. That is what tripped me up was not providing an ID for controls I knew I was not going to access or modify.
I did understand that /* [ #] */ is only a comment and that was helpful in keeping track of what was what. I left blank comments for controls that I was not numbering.
Many thanks to you for being Mr. AnswerMan for my continued discovery of dialog boxes and the Archicad API.
All the best,
Chris