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

Modal to Modeless

Anonymous
Not applicable
Hi developers,

I have alredy made an aplicattion who works properly with a Modal Dialog. Now, i would like to change this modal dialog into a Modeless one. But i have found some problems, due to when i run the API i can not interact with the Dialog and in few seconds, the application closes and error report starts. I have read the Developer's Manual and i can not see the problem. This is my function:


filNum = ACAPI_UseOwnResModule (); // Set own resource file the active one
//isOK = (DGModalDialog(CalcEnerMin_GDLGID, CalcEnerMinDlgCallBack,0) == DG_OK);
DGModelessInit(CalcEnerMin_GDLGID, CalcEnerMinDlgCallBack,0,1);
ACAPI_ResetResModule (filNum);


And here the GRC code:

'GDLG' 32530 Modeless 0 0 570 620 "Modeless"


I have also read something about the function "DGModelessHandler" but i am not sure if i should use it or not and how it works.

I will be really grateful if somebody could help me.
16 REPLIES 16
Ralph Wessel
Mentor
frankito5 wrote:
'GDLG' 32540 Modeless 0 0 320 250 "Prueba"
Have you tried making it a Palette? In the past, Modeless could crash because it wasn't correctly registered in ArchiCAD. I don't know if this has been corrected, but I would certainly try Palette instead.
Ralph Wessel BArch
Software Engineer Speckle Systems
Anonymous
Not applicable
Ralph wrote:
frankito5 wrote:
'GDLG' 32540 Modeless 0 0 320 250 "Prueba"
Have you tried making it a Palette? In the past, Modeless could crash because it wasn't correctly registered in ArchiCAD. I don't know if this has been corrected, but I would certainly try Palette instead.
Yes, i've tried and i just can see one difference. The outline of the Dialog seems diferent(exactly like modal dialog) but in few seconds the crash comes.

To be honest, i'm starting to think is a problem with Modeless and Palettes in archiCAD. I have tried with all the possibilites, and is not normal it works with Modal mode and, if i'm not forgetting anything, it does not work with modeless or palettes. Have you tried to create a Modeless dialog instead a Modal one?

Moreover, when i try to use different comands like 'DGCreatePalette' i have library problems(no idea):

1>DG_Test.obj : error LNK2019: símbolo externo __imp_DGCreatePalette sin resolver al que se hace referencia en la función "void __cdecl Prueba_Modeless(void)" (?Prueba_Modeless@@YAXXZ)
1>x64\Release\DG_Test.apx : fatal error LNK1120: 1 externos sin resolver



Anyway, maybe we can solve it by other way. Imagine i make a calculation in the Add-on about how many lines i have to draw. The problem is, when i'm working with a Modal dialogue i can't get this value and draw them. I have to close the dialog to draw this lines but if i close it i lose this value. Do you have an alternative?
Oleg
Expert
I dont know the reason.
Personally I use the Class implementation of DG module.
Just an idea.

Your AddOn should be "keep in memory" if you use a modeless or palette.
Else it will unloaded and dialog handler will invalid.
I think, you need to use ACAPI_RegisterModelessWindow, so I think, API will keep your AddOn in memory automatically.
Or try for test ACAPI_KeepInMemory.

PS: Sorry my poor English
Ralph Wessel
Mentor
Oleg wrote:
Your AddOn should be "keep in memory" if you use a modeless or palette.
Else it will unloaded and dialog handler will invalid.
Yes - that is probably the cause.
Ralph Wessel BArch
Software Engineer Speckle Systems
Anonymous
Not applicable
I think, you need to use ACAPI_RegisterModelessWindow, so I think, API will keep your AddOn in memory automatically.
Where i should call this function?
Or try for test ACAPI_KeepInMemory.
I have used this function and i got my goal even i still can't manage it from a modeless dialog but now i can link objects with the dialog(THANK YOU ). Last thing, i would like to know something new. I have drawn my own objects from my API and i would like to modify some attributes from my API. Which is the structure i have to modify? I've tried element.objetct.x where 'x' is the attribute to modify. But the attributes which i would like to modify are recently created by myself and i don't know which and where is the structure i have to handle.


There is some information in about in the Manual?
Ralph Wessel
Mentor
frankito5 wrote:
Where i should call ACAPI_RegisterModelessWindow?
From the documentation:
call it from the DG_MSG_INIT section of your palette's callback
frankito5 wrote:
I have drawn my own objects from my API and i would like to modify some attributes from my API. Which is the structure i have to modify? I've tried element.objetct.x where 'x' is the attribute to modify. But the attributes which i would like to modify are recently created by myself and i don't know which and where is the structure i have to handle.
Could you start this question on a new topic? Someone else might have the same question in future, and it will be much easier to find with under a specific title.

Can you expand on the question a bit too? When you say attributes, do you mean layers, pens, etc? Do you want to know how to save the object after the changes have been made?
Ralph Wessel BArch
Software Engineer Speckle Systems
Anonymous
Not applicable
Alredy postted in the Developer forum. I hope it can help also to other beginner developers.