Choose your top Archicad wishes!

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

[SOLVED] Is there a way to make a loading progress bar

Not applicable

I would like to know is there a way to make a loading progress bar by AC API.
I'm getting information from web service and somethimes it's take 10 second or more so I want to show loading process.
If there is not a solution by AC API then is it right to do it by third party library, for example by BOOST ?

Please give me an advice.
Tibor Lorantfy
Graphisoft Alumni
Graphisoft Alumni

yes, AC API provides two options to make progressbar:

1) You can use DG::ProgressBar class (defined in DGBarControl.hpp).
- first define the progressbar in your GRC resource file:
'GDLG'  32500  Modal | noGrow      0    0  312  195  "Dialog with ProgressBar" { 
/* [  6] */ ProgressBar			   13  140  286   15	/*minValue:*/ 0  /*maxValue:*/ 100  ClientEdge 

- add DG::ProgressBar to your dialog class:
class MyDialog : public DG::ModalDialog 
		// friend classes 
	friend class	MyObserver; 
	DG::ProgressBar		m_progressBar; 
	MyDialog (GSResModule dialResModule, short resId, GSResModule dialIconResModule); 
   ~MyDialog (); 

- in the constructor of your dialog don't forget to initialize the progressbar:
MyDialog::MyDialog (GSResModule dialResModule, short resId, GSResModule dialIconResModule): 
	DG::ModalDialog		(dialResModule, resId, dialIconResModule), 
	m_progressBar	(GetReference (), 6), 

- now you can use the initialized progressbar in you code the following way:
m_progressBar.SetValue (<new value between minValue and maxValue>);

2) You can use the ACAPI_Interface ProcessWindow methodgroup to show a processwindow with a progressbar.
// Init processwindow: 
	short nPhase	= 1; 
	Int32 maxValue	= 100; 
	ACAPI_Interface (APIIo_InitProcessWindowID, "<progressTitle>", &nPhase); // you can define more phases also 
// Start progressbar: 
	ACAPI_Interface (APIIo_SetNextProcessPhaseID, "<progressSubtitle>", &maxValue); 
// Update progressbar with new value: 
	Int32 progress = 0; 
	ACAPI_Interface (APIIo_SetProcessValueID, &progress, NULL); 
	ACAPI_Interface (APIIo_SetProcessValueID, &progress, NULL); 
// Processwindow contains a Cancel button also: 
	if (ACAPI_Interface (APIIo_IsProcessCanceledID, NULL, NULL)) { 
		// user cancelled the process! 

- This is much more easier.

Not applicable
Thank you for the help. I use second one!

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!