The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 WaitCursor
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

chintan

India
16 Posts

Posted - 06/17/2015 :  08:23:09 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. 8.0
Operating System:Win 7 - 64 Bit

Hi,
How we can show WaitCursor while the programme is doing somthing in background.I found WaitCursor() in help,but its not clear for me .
After execution how we can return to normal cursor ?

Regards,
Chintan.

cmbhatt

cdrozdowski111

USA
247 Posts

Posted - 06/17/2015 :  11:49:16 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
cmbhatt,

Typically when you declare a waitCursor object the cursor will immediately change and then revert back to the normal cursor once the current code scope (as defined by brackets {}) is finished. For example, if you declare it at the beginning of a function, when the function returns, the cursor will automatically be restored to the normal one.

For example:


void myfunc1()
{
	// Change to busy cursor with this declaration
	waitCursor wc;
	
	// Do something time consuming

	// When function returns, the cursor returns to normal
}


However, you can leverage the fact that declaring a waitCursor is scope-dependent. In the example below, I have added a set of brackets to give the waitCursor scope. After the closing bracket, the cursor will return to normal. One caveat with doing this sort of things is that it can complicate variable scoping so you have to be really careful doing it.


void myfunc2()
{

	// Add a set of brackets to create scope for the wait cursor.
	{
		waitCursor wc;
		
		// Do something time consuming in this scope and show waitCursor
	}
	// Outside of above bracket scope, cursor returns to normal

	// Now continue doing other things and cursor will be normal pointer.
}



I hope this helps,

Cheers,
Chris
Go to Top of Page

chintan

India
16 Posts

Posted - 06/18/2015 :  03:30:51 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Chris,
Thanks for your reply.
Is there any way to keep the cursor busy until the execution of 4,5 functions with out declaring it all the time ? Also is it possible to select the type of busy cursor ??

Regards,
Cmbhatt.

cmbhatt
Go to Top of Page

cdrozdowski111

USA
247 Posts

Posted - 06/18/2015 :  6:40:03 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You cannot chose the wait cursor- it is whatever the system designates as the wait cursor.

As far as when to use the wait cursor when calling multiple functions- play with the code below to see an example. As it is now, the wait cursor will run until all the functions within the same scope have run. Try commenting out the call in myfunc() and uncommenting those in the two other functions. You'll see the effect.

Cheers,
Chris


void myfunc()
{
	waitCursor junk;

	mywork1();
	Sleep(5000);
	mywork2();
}


void mywork1()
{
	//waitCursor junk;

	Sleep(5000);
}

void mywork2()
{
	//waitCursor junk;

	Sleep(5000);
}
Go to Top of Page

long123

China
9 Posts

Posted - 07/07/2015 :  03:10:16 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply

As far as when to use the wait cursor when calling multiple functions- play with the code below to see an example.

sbvdxfnbghm
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000