We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
2006-06-20 03:09 PM - last edited on 2023-08-07 11:13 AM by Doreena Deng
{ bool abort = false; CTestWindow window(abort); //modeless window with access to "abort" for (int i = 0; (i < 10) && !abort; i++) { Sleep(500); PRINT(GET(i)); } }
2006-06-20 06:32 PM
2006-06-20 09:33 PM
Akos wrote:
Try to use a palette instead. Modeless dialogs are special to ArchiCAD.
class CTest3Window { public: CTest3Window(); //creates a pallette with "DGCreateBlankPalette" ~CTest3Window(); void live(); //invokes "DGGetMousePosition" static short int DGCALLBACK mainEventHandler( short message, short dialId, short itemId, long userData, long msgData ); private: short mDialogId; };
CTest3Window::CTest3Window() { mDialogId = DGCreateBlankPalette ( 200, // hSize, 200, // vSize, DG_DLG_NOGROW, // growFlag, DG_DLG_CLOSE, // closeFlag, 0, // captionFlag, DG_DLG_NORMALFRAME, // frameFlag, this->mainEventHandler,// dCallBack, 0 //userData ); DGShowModelessDialog(mDialogId); DGBeginProcessEvents(mDialogId); DGSetModelessDialogStatus(mDialogId, DG_DS_ENABLED); } CTest3Window::~CTest3Window() { DGEndProcessEvents(mDialogId); DGDestroyModelessDialog(mDialogId); } void CTest3Window::live() { DGMousePosData mpd; short mouseStatus = DGGetMousePosition(mDialogId, &mpd); }
To make the loop breakable try calling something like DGGetMousePosition inside the loop; that lets other event handlers run.
for (int i = 0; (i < 10) && !abort; i++) { window.live(); //invokes "DGGetMousePosition" Sleep(500); }
The example you are referring to is the test application for the Dialog Manager (a.k.a DG) module.
2006-06-22 05:35 PM
John wrote:
The process-window which could be created with "ACAPI_Interface(APIIo_InitProcessWindowID,.." does not seem to work properly.
bool abort = false; short nPhase = 1; long maxval = 100; ACAPI_Interface (APIIo_InitProcessWindowID, "incremental search", &nPhase); ACAPI_Interface (APIIo_SetNextProcessPhaseID, "working...", &maxval); for (int i = 0; (i < maxval) && !abort; i++) { Sleep(500); PRINT(GET(i)); ACAPI_Interface(APIIo_SetProcessValueID, &i, NULL); if (ACAPI_Interface(APIIo_IsProcessCanceledID, NULL, NULL)) { abort = true; } } ACAPI_Interface (APIIo_CloseProcessWindowID, NULL, NULL);
2006-06-24 10:14 AM
John wrote:John,
Now, I am using "APIIo_InitProcessWindowID" after all...
It takes a long time before the process-window appears.
So if the process does not takes long enough you don't see this window. Thats why i thought it would not work.
John wrote:The crux of the problem is that much of ArchiCAD has not been designed to support threading. That's why it crashes when a separate thread attempts to access the database.
[Threads]
An other way i tried was the following:
I coded a Status-Window which is able to invoke the method whose status is to be monitored in a new thread.
But there were several problems:
1. The thread I used is not OS-independent and I think you should avoid OS-specific code in AC-Addons.
2. ArchiCAD often crashes, if the method running in the thread is selecting elements or changing the AC-database.