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

How to send a message to the created palette

satoshi shimokura
Contributor

hello. I am developing using API Development Kit 25.3002 (Windows).

 

I would like to send a DG_MSG_CHANGE message to the radio buttons in the palette I created.

The DGSendMessage function was described in the manual, so I tried to use it I'm having trouble finding an implementation.

 

I found the DGSendUserMessage function instead, but I don't know how to give the third argument DG::EventArg& msgData.

 

Is it correct to use DGSendUserMessage to send a message to the palette in the first place?

In addition, I tried to get the window handle with ACAPI_GetMainWindow or DGGetDialogWindow and execute the WindowsAPI SendMessage function.

It was no good.

 

Is there a way to send a message to the created palette?

Thank you very much.

1 ACCEPTED SOLUTION

Accepted Solutions
Solution
LABPP
Contributor
If you get a pointer to a listbox in C++, then this works:

SingleSelListBox *lb;
lb->SelectItem(item);
DG::ItemSelectionChangeEventArg eventarg;
lb->onSelectionChanged.NotifyAll(*lb,eventarg);

View solution in original post

10 REPLIES 10

Hi!

I also can't find the DGSendMessage function although it's documented. This is weird. But it has the same signature as the DialogHandlers itself. So you could just call the DialogHandler of the palette directly; that's actually something I've already used before:

DialogHandler (DG_MSG_CHANGE, dlgID, itemID, msgData);

 msgData can be "anything" if you don't use it in the DialogHandler. Otherwise you can check the used values in the documentation of the Dialog messages.

Hope that helps,
Bernd

Bernd Schwarzenbacher - Archicad Add-On Developer - Get Add-Ons & Archicad Tips on my Website: bschwb.com

As bschwb says
Give up sending the message itself,
Although it is not DialogHandler, I achieved my goal by calling the target function directly.

 

Thank you for taking your precious time to reply.


However, it is described in the DialogManager item of the manual (e.g. RadioButton.html)
Messages like DG_MSG_CHANGE and DG_MSG_DOUBLECLICK are the mystery.

 

For example, in the case of RadioButton, when the button is pressed, instead of PaletteAPIControlCallBack RadioItemChanged is called.

Where can I receive DG_MSG_CHANGE when this radio button is operated?

 

This may be an immature question. very sorry.

If RadioItemChanged is called, then you are using the newer "C++" class style of UI handling for your palette.
From your previous question I wrongly assumed that you were using the old "C-style", Sorry!

 

I cite myself from a different answer to clarify further:

There are 2 "styles" of handling Dialogs and their items. The "older" C style (which is decently documented in the offline documentation.). This style uses Handlers and you need to register them. As a contrast there's the "newer" C++ style which is less documented unfortunately. Here you create Classes/Objects for your Dialogs, Items etc. Instead of Handlers you work more with Event Observers. It's a rough distinction but I hope it helps anyway.


So in your case I think you are using the newer C++ style. So the DG_MSG_CHANGE messages etc. are not really relevant. I would recommend you stay completely in the C++ Style and use the correct observer classes and events.

So instead of receiving DG_MSG_CHANGE, you work with the RadioItemChanged method. And instead of receiving DG_MSG_DOUBLECLICK you work with the RadioItemDoubleClicked method.

Feel free to ask further questions if this doesn't help.
Bernd

Bernd Schwarzenbacher - Archicad Add-On Developer - Get Add-Ons & Archicad Tips on my Website: bschwb.com

bschwb

 

Thank you for your reply.

 

I didn't know there was such a thing as the old "C-style"
I posted with too little information.

I'm sorry.

 

However, I was able to know that such a thing exists through this exchange, and I learned a lot.

The purpose itself was achieved by the first response I received.
As you said, I will continue to use the new "C++ style".

 

Thank you very much for your kind reply.

Solution
LABPP
Contributor
If you get a pointer to a listbox in C++, then this works:

SingleSelListBox *lb;
lb->SelectItem(item);
DG::ItemSelectionChangeEventArg eventarg;
lb->onSelectionChanged.NotifyAll(*lb,eventarg);
LABPP

I tried it with my own code and it certainly worked.
It's a function that's not even in the manual, so I'd be very grateful if you could let me know.

I would like to try this method as well.
Thank you.

Hi, Satoshi!
In the documentation for API Archicad 17, there was still a full description of dialog classes and control elements in dialogs.
If necessary, I will send.
Some new changed properties have to be seen in .hpp files.

LABPP

I am very grateful for that.
Please by all means.

 

Satoshi, send me Your email to mail [at] labpp [dot] ru