Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. newbie question

newbie question

Scheduled Pinned Locked Moved C / C++ / MFC
questionarchitecturehelpannouncement
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MVH
    wrote on last edited by
    #1

    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 ;)

    C 1 Reply Last reply
    0
    • M MVH

      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 ;)

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      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

      M 1 Reply Last reply
      0
      • C Christian Graus

        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

        M Offline
        M Offline
        MVH
        wrote on last edited by
        #3

        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?

        O C 2 Replies Last reply
        0
        • M MVH

          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?

          O Offline
          O Offline
          Ozgur Aydin Yuksel
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • M MVH

            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?

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #5

            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

            M 1 Reply Last reply
            0
            • C Christian Graus

              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

              M Offline
              M Offline
              MVH
              wrote on last edited by
              #6

              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).

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups