 |
|
 |
Thanks Chris... This is really cool.
Cheers
-Ranga
|
|
|
|
 |
|
 |
very nice, thanks
My Blog: http://cynicalclots.blogspot.com
|
|
|
|
 |
|
 |
Hi,
I added a pb in my app and it just freezes
void CMainFrame::ShowProgressBar()
{
m_bIsPBCanceled = false;
if(!wndProgress.Create(0, "TDO - KODAK RVG6000"))
return;
wndProgress.SetRange(0,90000);
wndProgress.SetText("Waiting for X-ray...");
for(int i=0; i<90000; i++)
{
wndProgress.StepIt();
if (wndProgress.Cancelled())
{
break;
}
}
wndProgress.DestroyWindow();
}
Anybody had same experience? Any ideas what could be causing the problem?
I also would like to know how to cancel it if i get a specific message from other object.
For instance, suppose m_bIsPBCanceled = true now, where m_bIsPBCanceled is public bool variable in CMainFrame.
Thanks in advance
|
|
|
|
 |
|
 |
The application source code compiled fine in VS 2008; however when I rebuild the project in VS 2008 and executed the application code for displaying the progress window, it crashes in
BOOL CProgressWnd::Create(CWnd* pParent, LPCTSTR pszTitle, BOOL bSmooth /* = FALSE */)
{ .
.
VERIFY(SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0));
..
}
Please help!
|
|
|
|
 |
|
 |
Change:
ncm.cbSize = sizeof(NONCLIENTMETRICS);
to
ncm.cbSize = sizeof(NONCLIENTMETRICS) - sizeof(int);
will fix the crash in
VERIFY(SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0));
|
|
|
|
 |
|
 |
I think this change would be more appropriate fix.
ncm.cbSize = sizeof(NONCLIENTMETRICS);// - sizeof(int);
#if(WINVER >= 0x0600)
OSVERSIONINFO versionInfo;
versionInfo.dwOSVersionInfoSize = sizeof( versionInfo );
GetVersionEx( &versionInfo );
// If we are running under XP, deduct the size of the
// iPaddedBorderWidth member added in Vista.
if ( versionInfo.dwMajorVersion < 6 )
{
ncm.cbSize -= sizeof(int);
}
#endif
I wish I could credit for this, but I shamelessly copied the code form here:
http://www.roguewave.com/forum/archive/index.php?t-37.html[^]
|
|
|
|
 |
|
 |
#if _MSC_VER == 1200
// VC6.0
ncm.cbSize = sizeof(NONCLIENTMETRICS);
#else
// VS
ncm.cbSize = sizeof(NONCLIENTMETRICS) - sizeof(ncm.iPaddedBorderWidth);//sizeof(NONCLIENTMETRICS);
#endif
/************************************************************************/
/* MS VC++ 10.0 _MSC_VER = 1600 */
/* MS VC++ 9.0 _MSC_VER = 1500 */
/* MS VC++ 8.0 _MSC_VER = 1400 */
/* MS VC++ 7.1 _MSC_VER = 1310 */
/* MS VC++ 7.0 _MSC_VER = 1300 */
/* MS VC++ 6.0 _MSC_VER = 1200 */
/* MS VC++ 5.0 _MSC_VER = 1100 */
/************************************************************************/
VERIFY(SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0));
m_font.CreateFontIndirect(&(ncm.lfMessageFont));
|
|
|
|
 |
|
 |
I tried dropping the two source files into my VC++ (Visual Studio 2005 Pro) project and including them, but I get over a hundred compile errors, the first (and seemly most symptomatic) being:
ProgressWnd.h(36) : error C2504: 'CWnd' : base class undefined
Research seems to indicate that this is an MFC vs. .NET compatibility problem and that I need to make some reference or set something in my project properties for it to work. I have tried copying lines from the demo's stdafx.h file into mine, but that produces errors such as "window.h is already included".
In the course of trying to correct this problem, I also somehow managed to get the following error:
fatal error C1189: #error : Building MFC application with /MD[d] (CRT dll
version) requires MFC shared dll version. Please #define _AFXDLL or do not
use /MD[d] c:\program files\microsoft visual studio
8\vc\atlmfc\include\afx.h
but since playing around with the stdafx.h file, I have not been able to reproduce this error.
Do you know what could be causing these problems and how I can fix them?
Luke
|
|
|
|
 |
|
 |
I have the same problem. Maybe a similar class, made for .NET, would be the solution.
|
|
|
|
 |
|
 |
Hi all,
I use the control in my solution, and when I should update the progress I add a SetText new string too. Look at the code:
CString tempProgress;
tempProgress.Format(_T("Loading file %d/%d...\n\nPlease Wait."), i, m_NumFiles);
m_pProgress->SetText(tempProgress);
m_pProgress->StepIt();
m_pProgress->PeekAndPump();
But when I run into this, I get very ugly flickering, and I have no idea how destroy it.
I also try to use Invalidate(FALSE), I also try to change the return of value of OnEraseBkgnd event, but no way.
Could you help me?
Thank you
Walxer
|
|
|
|
 |
|
 |
Thank you Chris for this control : The PeekMessage is the key to evry thing : sofar I use two thread, with the main thread creating the progress window, and the worker thread doing the job and reporting progress to the main.
Now evrything happen in one thread !
Thank you again.
|
|
|
|
 |
|
 |
I initiated the progress window in my MainFrm and it works great, but how do I access the same progress window from other parts of my program? I need a 2 part progress display. First half of my process is done in MainFrm and the other half is done in the other part of my program. I would like to update progress window text and continue stepping for the 2nd half of my process.
Ideally what I want to accomplish is to use same progress window for my entire process.
Great job on this Popup Progress Window!
WVP
|
|
|
|
 |
|
 |
Hello WVP !
Of course in your case, you should avoid creating the ProgressWnd object in local functions: instead put the object as a memeber of your mainframe class for example, then provide your self with a mean to access that object (you can access the main frame from any location : AfxGetMainWnd followed by a cast), finally when you shift from a task to task, just call the clear() memeber and rest the text and the value range !!
|
|
|
|
 |
|
 |
Thanks. Clear and useful.
|
|
|
|
 |
|
 |
Hi,
Do you know how to do it in .NET Winforms?
_slav_
|
|
|
|
 |
|
 |
Nice work. it was amazing to my project!
Thanks
|
|
|
|
 |
|
 |
I tried to use this dialog in a worker thread, after I click the cancel button, the whole program stopped response until it totally finish, Can you solve the problem? Thanks
|
|
|
|
 |
|
 |
I also encountered this problem ,any solution?
|
|
|
|
 |
|
 |
Hi there,
thank you for this great class!
Unfortunately the Progress Window crashes if i move the mouse over the Dialog.
I use this Dialog without a parent window. If the dialog runs without moving the mouse over it, it works fine.
If i debug my program i get stuck on this line:
AfxGetApp()->PumpMessage()
in the PeekAndPump method.
Any suggestions?
-- modified at 10:57 Wednesday 25th January, 2006
|
|
|
|
 |
|
 |
I got it.
For those who got the same problems:
Because i used this Method in a DLL Project i had to switch to a few API-Functions.
I just replaced the LOOP (AfxGetApp()->PumpMessage()) with
if ( ::GetMessage(&msg, NULL, 0, 0))
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
else
{
::PostQuitMessage(0);
break;
}
Now it works fine!
|
|
|
|
 |
|
 |
I downloaded the sample and it looks cool.
But whenever my code tries to initialize an object of class CProgressWnd, I get an Assert from winocc.cpp on line 279. I am trying to display the progress dialog from another modal dialog. I don't think this should be a problem though, should it ?
Perhaps I'm not passing the correct *Cwnd as the first parameter. I've tried "this" and "NULL" but neither seem to work. I'm using VC++ 6.0 with service pack 6. I would really appreciate any ideas that may help.
Thanks
Ethann
|
|
|
|
 |
|
 |
thanks for that - it's very convenient!
|
|
|
|
 |
|
 |
Hi!
I want to get information from a message box
you can help me
thans
|
|
|
|
 |
|
 |
Can this Class be used for Console Applications . If so can anyone pump one
example..
|
|
|
|
 |
|
 |
I haven't seen anyone else run into this problem, but I did so I thought I'd share in case it helps someone.
Scenario: When the user clicks a CBitmapButton button and the on-click handler displays the progress window, the button will show on top of the progress window
Workaround: After instantiating the progress window object, call SetWindowPos:
CTAProgressWnd wndProgress(NULL, "Progress");
wndProgress.SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
Cheers,
Tom Archer - Archer Consulting Group
Programmer Trainer and Mentor and Project Management Consultant
|
|
|
|
 |