Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

BeginWaitCursor & EndWaitCursor Do Not Work in Other than Main Thread

519 views
Skip to first unread message

Manish Bhatia

unread,
Aug 19, 2002, 2:12:54 AM8/19/02
to
BeginWaitCursor & EndWaitCursor Do Not Work in Other than Main Thread,

Can Someone tell why ? & How To Implement Such Behavior if Reqd

I am Trying it To Implement using SetClassLong It Has its Problem

1) The Mouse Click is not Stopped Just the Cursor is Changed

2) It Needs To be Done with every Window & Then restored after the operation

Help Please ...............

Code Example .................

HCURSOR Busy = ::LoadCursor(NULL,IDC_WAIT);
HCURSOR Normal = ::LoadCursor(NULL,IDC_ARROW);
UINT Proc(LPVOID arg)
{
CCursorWithThreadDlg *p=(CCursorWithThreadDlg *)arg;
p->DoSomeWork();
return 0;
}
void CCursorWithThreadDlg::OnButton1()
{
::AfxBeginThread(Proc,this);
}

void CCursorWithThreadDlg::DoSomeWork()
{
// SetClassLong(GetDlgItem(IDC_BUTTON1)->m_hWnd,GCL_HCURSOR,(LONG)Busy);
BeginWaitCursor();
CString data;
for(int i=1;i<=9999;i++)
{
// SetCursor(Busy);
RestoreWaitCursor();
data.Format("%d",i);
this->m_ctrlTest.SetWindowText(data);
}
EndWaitCursor();
// SetClassLong(this->m_hWnd,GCL_HCURSOR,(LONG)Normal);


}


David Lowndes

unread,
Aug 19, 2002, 7:45:47 AM8/19/02
to
>BeginWaitCursor & EndWaitCursor Do Not Work in Other than Main Thread,

They only work when the main UI thread is not processing messages. As
soon as the UI thread handles a WM_SETCUROR message the default
processing resets the cursor to the window's class default cursor.

If you want to show a different cursor during a long operation when
messages will be processed, handle the WM_SETCURSOR message and change
the cursor from there.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.

unfortuna...@yahoo.com

unread,
Aug 23, 2002, 3:24:32 AM8/23/02
to

Checkout CWaitCursor class. It would be helpful for you.

>.
>

Manish Bhatia

unread,
Aug 23, 2002, 5:06:59 AM8/23/02
to
I have Checked Out CWaitCursor class its behavior is same as that for
beginwaitcursor & EndWaitCursor.
I suppose that the Reply from David Lowndes <dav...@mvps.org>
Should Work Out.However I am Working On It.


0 new messages