newbie question
-
I'm building a program, and I have this problem: - I got CDocument/CView architecture - In CMyAppDoc is CMyClass object - In CMyClass object is a function SolveProblem() - In SolveProblem is a loop that is working on a certain problem How can I from _inside that loop_ update the screen? That way I could see the progress. Two threads? How? I put SolveProblem work in another, and then...? Just kick me in the right direction, no need to kick me all the way ;)
-
I'm building a program, and I have this problem: - I got CDocument/CView architecture - In CMyAppDoc is CMyClass object - In CMyClass object is a function SolveProblem() - In SolveProblem is a loop that is working on a certain problem How can I from _inside that loop_ update the screen? That way I could see the progress. Two threads? How? I put SolveProblem work in another, and then...? Just kick me in the right direction, no need to kick me all the way ;)
Invalidate(FALSE); tells the screen to update itself, making the parameter TRUE also tells it to erase itself. If you're showing progress in a progress bar, it has a method to set it's level, and any control that contains text can be updated with SetWindowText, which will invalidate the control. You probably want the latter methods, I would think. Oh, UpdateData(FALSE) ( from memory ) does it for you if you have controls and have made variables that are CStrings. Christian Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
-
Invalidate(FALSE); tells the screen to update itself, making the parameter TRUE also tells it to erase itself. If you're showing progress in a progress bar, it has a method to set it's level, and any control that contains text can be updated with SetWindowText, which will invalidate the control. You probably want the latter methods, I would think. Oh, UpdateData(FALSE) ( from memory ) does it for you if you have controls and have made variables that are CStrings. Christian Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
How can I get a pointer to CWnd object to be able to use Invalidate? Invalidate is a member of CWnd, while my loop runs in CMyClass (which is a member variable of CMyAppDoc). From MS VC++6 help: CWnd::Invalidate void Invalidate( BOOL bErase = TRUE ); - - - - - I could rephrase the question: How to cause screen update from a loop inside my own class?
-
How can I get a pointer to CWnd object to be able to use Invalidate? Invalidate is a member of CWnd, while my loop runs in CMyClass (which is a member variable of CMyAppDoc). From MS VC++6 help: CWnd::Invalidate void Invalidate( BOOL bErase = TRUE ); - - - - - I could rephrase the question: How to cause screen update from a loop inside my own class?
Check AfxGetMainWnd which you can access your CMainFrame object. You can access main frame at any place in your code and updating main frame shall update all windows (I'm not sure with the last one but it should work). Or from that point you can access the window that you want to update. ozgur.
-
How can I get a pointer to CWnd object to be able to use Invalidate? Invalidate is a member of CWnd, while my loop runs in CMyClass (which is a member variable of CMyAppDoc). From MS VC++6 help: CWnd::Invalidate void Invalidate( BOOL bErase = TRUE ); - - - - - I could rephrase the question: How to cause screen update from a loop inside my own class?
Sorry - I did not get that you were outside your window. As has been said, AfxGetMainWnd, and if you cast the return value to CMainframe, you can get access to views, etc. Better yet would be to pass the pointer in from the window when you call the method. Christian Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
-
Sorry - I did not get that you were outside your window. As has been said, AfxGetMainWnd, and if you cast the return value to CMainframe, you can get access to views, etc. Better yet would be to pass the pointer in from the window when you call the method. Christian Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
Yes, that would be the best solution. I already catch the Menu command in CView class object, I'll just pass the CView pointer to my own class (I get the pointer to my own class object from pDoc), and then I can use the Invalidate() inside my own class. I seem to always try to cut down the number of passed parameters and look for other ways of getting the needed information (usually pointers).