Forum
Please
Log In
to post a new message or reply to an existing one. If you are not registered, please
register.
NOTE: Some forums may be read-only if you are not currently subscribed to
our technical support services.
Subject |
Author |
Date |
|
ernest peters
|
Feb 9, 2005 - 8:47 PM
|
Hi Guys, Can you please post me a snippet on how i can update my progress bar (located on the main frames status bar) from a dynamically created second thread (the thread does some background comms work which may take a couple of minutes)? I am getting an ASSERT_VALID error on the ’this’ pointer of the status bar.
I can post code if required.
|
|
Technical Support
|
Feb 10, 2005 - 5:49 AM
|
MFC does not allow you to share CWnd -pointers between threads. So, if you created a progress bar in the main thread, you can use its window handle (HWND ) in another thread (but not a pointer to CWnd or CProgressBar ). In this case, just use a standard Windows message with a handle of the progress bar instead of using its methods:::SendMessage(hProgressWnd, PBM_STEPIT, 0, 0L)
Another way is to create CProgressBar in the required thread. This allows you to avoid cross-thread messaging and update the progress bar smoother.
|
|