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

how to stop it from closing in Modai Dialog (Enter key or ESC key )

nishida_jp
Participant

I am programming a c++ add-on using ArchiCAD27API + Visual Studio 2019 + Windows 10.

When I press the Enter key or ESC key in the Modai Dialog, the dialog closes.

Please tell me how to stop it from closing

5 REPLIES 5
Oleg
Expert

Use the PanelCloseRequested of the PanelObserver.

See the AddRenameViewPointItemDialog.cpp of Navigator_Test example.

Thank you for your reply.
My program uses DGModalDialog() and I can't perform the processing you suggested.
If you know of any other ways, please let me know.

Oleg
Expert

There is DG_MSG_CLOSEREQUEST message.
But unfortunately, it is not documetnted. I use C++ dialogs, and i dont know any details, sorry.

Thank you.

I try DG_MSG_CLOSEREQUEST.

Miklos Vegh
Graphisoft
Graphisoft

You use a C-style dialog if I am correct.
In C-style dialogs the DG_MSG_CLOSEREQUEST is not used.

When you click the Ok or Cancel button or pess Esc/Enter, a DG_MSG_CLICK message is sent. If you return a 0 value in response of this message then the dialog will not be closed.
In general the dialog handler returns the button identifier for Ok/Cancel which enables the dialog to close, but you can return 0 to prevent closing the dialog:

 

case DG_MSG_CLICK:
	switch (itemId) {
		case DG_OK:
		case DG_CANCEL:
			if (doNotCloseDialog) {
				return 0;
			}
			return itemId;
		case AnyOtherButton:
			...
			return 0;

 

An other approach could be to use the DGRegisterHotKey function to steal the Esc/Enter keyboard events and not allow them to be processed by the dialog. In this case the dialog will accept the click events on the Ok/Cancel button but refuse to respond to the Enter/Esc keys.