Modal to Modeless
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2011-09-12
02:59 PM
- last edited on
‎2023-08-03
09:36 AM
by
Doreena Deng
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.
- Labels:
-
Add-On (C++)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2011-09-13 12:35 PM
frankito5 wrote:Try making the dialog a palette rather than a modeless dialog - I believe there may still be underlying problems registering a modeless dialog correctly from the API.
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.
Did you find the documentation for
Central Innovation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2011-09-14 01:46 PM
static void Prueba_Modeless (void){
GSResModule filNum;
short modelessID;
filNum = ACAPI_UseOwnResModule (); // Set own resource file the active one
//modelessID = DGModelessInit(Modeless_GDLGID, ModelessDlgCallBack, 0, 0);
modelessID = DGCreateBlankModelessDialog(320,250,DG_DLG_NOGROW,DG_DLG_CLOSE,DG_DLG_MINIMIZE,DG_DLG_MAXIMIZE,DG_DLG_NOCAPTION,DG_DLG_THICKFRAME,ModelessDlgCallBack,0);
if(modelessID != 0){
DGBeginProcessEvents(modelessID);
DGShowModelessDialog(modelessID, DG_DF_FIRST);
}
ACAPI_ResetResModule (filNum);
return;
}
With the red one i have compiling problems(i can not understand it). The same if i try with the Palette instead of Modeless as u suggested me:
DG_Test.obj : error LNK2019: sĂmbolo externo __imp_DGCreateBlankModelessDialog sin resolver al que se hace referencia en la funciĂłn "void __cdecl Prueba_Modeless(void)" (?Prueba_Modeless@@YAXXZ)
With the green one, the Dialog appears but i cant operate or move it and in few seconds, bug problems dialog appear and archiCAD closes.
Am i forgetting something

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2011-09-14 04:00 PM
frankito5 wrote:Have you determined where the crash is occurring (e.g. with the debugger)?
With the green one, the Dialog appears but i cant operate or move it and in few seconds, bug problems dialog appear and archiCAD closes.
Central Innovation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2011-09-15 10:06 AM
I have printed some values to know where the program crashes but everything seems good. I show it:
static void Prueba_Modeless (void){
GSResModule filNum;
short modelessID;
ofstream mod("modeless.txt");
filNum = ACAPI_UseOwnResModule (); // Set own resource file the active one
modelessID = DGModelessInit(Modeless_GDLGID, ModelessDlgCallBack, 0, 0);
mod << "Create Dialog " << modelessID << endl;
//modelessID = DGCreateBlankModelessDialog(320,250,DG_DLG_NOGROW,DG_DLG_CLOSE,DG_DLG_MINIMIZE,DG_DLG_MAXIMIZE,DG_DLG_NOCAPTION,DG_DLG_THICKFRAME,ModelessDlgCallBack,0);
if(modelessID != 0){
DGBeginProcessEvents(modelessID);
mod << "Begin process" << endl;
DGShowModelessDialog(modelessID, DG_DF_FIRST);
mod << "Show Dialog" << endl;
}
ACAPI_ResetResModule (filNum);
mod << "Reset Module" << endl;
return;
}
Here, all the sentences are written in the .TXT file and also the value of the Dialog(32540 in this case). It means, the Dialog is created without any problem.
static short DGCALLBACK ModelessDlgCallBack (short message, short dialId, short itemId,
DGUserData /*userData*/, DGMessageData /*msgData*/){
short alto=0, ancho=0;
itemId=itemId;
ofstream mod2("modelessCall.txt");
mod2 << "START" << endl;
switch (message) {
case DG_MSG_INIT:
mod2 << "INIT" << endl;
DGGetDialogSize (dialId, DG_ORIGFRAME, &ancho, &alto);
//void DGSetDialogSize (short dialId,short rectType,short hSize,short vSize,short fixPoint,bool keepOld);
//DGSetDialogSize (dialId, DG_CLIENT, ancho, alto, DG_TOPLEFT, true);
break;
case DG_MSG_CLOSE:
mod2 << "CLOSE" << endl;
break;
case DG_MSG_CHANGE:
mod2 << "CHANGE" << endl;
break;
case DG_MSG_CLICK:
mod2 << "CLICK" << endl;
break;
}
mod2 << "EXIT" << endl;
return(0);
}
Here, START and EXIT are written. It's supossed INIT has to appear also, but i think it does not because of the callback behaviour. But i have tried to comment 'DGSetDialogSize ' and the Dialog really dont change the size so it get into INIT case.
I think i am forgetting something in the Callback, but i am not sure. Could be something related with the 'DGModelessHandler'? It converts the system messages in DG messages but i don't know it is necessary. Some suggestions? I am blocked and i do not know how to continue

THANKS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2011-09-15 11:07 AM
frankito5 wrote:Sorry, I can't pinpoint what's going wrong here. There are some redundancies in your code, but they wouldn't cause a crash, e.g. the following does nothing:
I think i am forgetting something in the Callback, but i am not sure. Could be something related with the 'DGModelessHandler'? It converts the system messages in DG messages but i don't know it is necessary. Some suggestions? I am blocked and i do not know how to continue
itemId=itemId;...and it is unnecessary to call
I think it is very important to determine the point where the add-on crashes - it may have nothing to do with the dialog. The stack trace could provide important clues to the reason for the failure. I'm surprised the debugger isn't trapping the crash - are you sure you're running the debug version and have at least one breakpoint set? If you're debugging with Visual Studio, it might also be useful to turn on all the runtime checks too.
Central Innovation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2011-09-15 12:21 PM
Ralph wrote:frankito5 wrote:
I think it is very important to determine the point where the add-on crashes - it may have nothing to do with the dialog. The stack trace could provide important clues to the reason for the failure. I'm surprised the debugger isn't trapping the crash - are you sure you're running the debug version and have at least one breakpoint set? If you're debugging with Visual Studio, it might also be useful to turn on all the runtime checks too.
I will try to find it, but i'm sure is something about dialog modes, because the same add-on works properly with Modal Dialog. If you have time, check it in the API Development Kit 14 in the DG_TEST example. Try to change one Modal Dialog to a Modeless and you will see the same problem(I have alredy checked it). That's why i can't understand the problem...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2011-09-15 01:23 PM
Exception code: C0000005 ACCESS_VIOLATION writing location: 0000000180004860
Primera excepciĂłn en 0x76fccb23 en ArchiCAD.exe: 0xC0000005: InfracciĂłn de acceso al leer la ubicaciĂłn 0x0000000180004860.
Fault address: 0000000180004860 (ILLEGAL)
I can't see info with the breakpoints because when y press f5, arhiCAD runs and when i open de addON from the Menu, the dialog appears and in few seconds archiCAD is closed and also de debugger mode.
Now, could you give me more information about possible solutions??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2011-09-15 02:07 PM
frankito5 wrote:What about the stack trace? This will tell you where the crash occurred and - more importantly - the call sequence leading up to it.
When im debugging, the report gives the following information:[]
Now, could you give me more information about possible solutions??
Just to confirm - have you changed the dialog resources in these tests to identify it as a palette rather than a modeless dialog?
Central Innovation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2011-09-15 02:40 PM
What about the stack trace? This will tell you where the crash occurred and - more importantly - the call sequence leading up to it.Call stack:
0x0000000180004870!ArchiCAD.exe + -2147465104
0x000000005FCA6ADB!DG.dll + 748251 (DGGetDialogResourceModule + 923 bytes)
0x000000005FC8DBF9!DG.dll + 646137 (DGEndProcessEvents + 3113 bytes)
0x000000005FC8FECD!DG.dll + 655053 (DGEnableMessage + 2345 bytes)
0x000000005FC90FEB!DG.dll + 659435 (DGBeginProcessEvents + 4347 bytes)
0x000000005FCC7016!DG.dll + 880662 (DGSetModelessDialogState + 554 bytes)
0x0000000077368971!USER32.dll + 100721 (GetWindowDC + 129 bytes)
0x00000000773672CB!USER32.dll + 94923 (SetWindowTextW + 631 bytes)
0x0000000077366829!USER32.dll + 92201 (IsDialogMessageW + 361 bytes)
0x00000000776B1225!ntdll.dll + 332325 (KiUserCallbackDispatcher + 31 bytes)
0x000000007736685A!USER32.dll + 92250 (IsDialogMessageW + 410 bytes)
0x0000000077363838!USER32.dll + 79928 (GetWindowLongPtrA + 120 bytes)
0x0000000077366BAD!USER32.dll + 93101 (SendMessageW + 93 bytes)
0x000007FEFC31645C!UxTheme.dll + 25692 (DrawThemeParentBackgroundEx + 340 bytes)
0x000007FEFC762D80!COMCTL32.dll + 667008
0x00000000127D5740!UNKNOWN_MODULE
0xFFFFFFFFF7011F90!UNKNOWN_MODULE
0x0000000000000001!ArchiCAD.exe + 1
0x000000000012EED8!UNKNOWN_MODULE
0x000000000012EEF8!UNKNOWN_MODULE
0x00000000026FE270!UNKNOWN_MODULE
0x000000000012EE01!UNKNOWN_MODULE
0x0000000100000001!ArchiCAD.exe + 1
Just to confirm - have you changed the dialog resources in these tests to identify it as a palette rather than a modeless dialog?'GDLG' 32540 Modeless 0 0 320 250 "Prueba" {
/*1*/ Button 190 255 80 20 LargePlain "Aceptar"
}
'DLGH' 32540 DLG_32540_Modeless {
1 "" Button_0
}