locked
MFC, updating the controls every few seconds RRS feed

  • Question

  • I'm pretty new in Win32 programming. Used to program c++ on devcpp, small, cute and simple IDE. The only thing i didnt like is the fact that i cant make the applications look as good as they operate, so I tried the MFC on VC++ 2008. It was cool, simple and I liked it.
    The only problem I have is the fact that I dont know how to update the dialog window every few seconds (like displaying Ping values for server... for example. Needs to be calculated and then displayed in the dialog).
    I tried everything, to derive the CDialog from CThread, tried even to make the dlg object global (so i can access it with the Run() of the Application class CWinApp. Its the 5th day I'm trying to understand what to do!!

    P.S
    I dont belive that you guyes, managed to create windows, all this classes but didnt put an option for self updating... lol, its just funny.

    Anyway, tnx!
    Help appreciated.
    Wednesday, October 14, 2009 1:23 AM

Answers

  • You probably want to create a timer.

    See this tutorial on timers for more details .
    Reed Copsey, Jr. - http://reedcopsey.com
    Wednesday, October 14, 2009 1:32 AM
  • I tried everything, to derive the CDialog from CThread, tried even to make the dlg object global (so i can access it with the Run() of the Application class CWinApp. Its the 5th day I'm trying to understand what to do!!

    CWinApp::Run() provides the message loop to acquires and dispatches Windows messages, what do you want to do here?
    In MFC, CWnd::UpdateData with CWnd::DoDataExchange are used to update the data in the dialog, CWnd::Invalidate can do the refreshing, you could check the documentation of them in MSDN, call CWnd::Invalidate in the timer handler to refresh the window.

    Sincerely,
    Wesley
    Please mark the replies as answers if they help and unmark them if they provide no help. Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Wesley Yao Tuesday, October 20, 2009 3:02 AM
    Thursday, October 15, 2009 3:43 AM

All replies

  • You probably want to create a timer.

    See this tutorial on timers for more details .
    Reed Copsey, Jr. - http://reedcopsey.com
    Wednesday, October 14, 2009 1:32 AM
  • Yay! Thanks.
    So you guyes did think about it after all?
    Wednesday, October 14, 2009 9:32 AM
  • I tried everything, to derive the CDialog from CThread, tried even to make the dlg object global (so i can access it with the Run() of the Application class CWinApp. Its the 5th day I'm trying to understand what to do!!

    I dont belive that you guyes, managed to create windows, all this classes but didnt put an option for self updating... lol, its just funny.


    1. ) What is CThread class? why do you need to derive?

    2. ) Did you check what is WM_PAINT message?


    Using timers is not a good practice to update the control.


    Knowledge is like light; It spreads only when you have clear and transparent mind. -Sreedhar
    Wednesday, October 14, 2009 11:52 AM
  • I tried everything, to derive the CDialog from CThread, tried even to make the dlg object global (so i can access it with the Run() of the Application class CWinApp. Its the 5th day I'm trying to understand what to do!!

    CWinApp::Run() provides the message loop to acquires and dispatches Windows messages, what do you want to do here?
    In MFC, CWnd::UpdateData with CWnd::DoDataExchange are used to update the data in the dialog, CWnd::Invalidate can do the refreshing, you could check the documentation of them in MSDN, call CWnd::Invalidate in the timer handler to refresh the window.

    Sincerely,
    Wesley
    Please mark the replies as answers if they help and unmark them if they provide no help. Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Wesley Yao Tuesday, October 20, 2009 3:02 AM
    Thursday, October 15, 2009 3:43 AM