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. Problems with screen redrawing [modified]

Problems with screen redrawing [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
debugginghelpquestioncode-review
8 Posts 5 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.
  • K Offline
    K Offline
    kildareflare
    wrote on last edited by
    #1

    Hello I've searched google and MSDN but cannot search the forums here yet as it keeps timing out. I've managed to improve my problem butnot completely resolve it. My application is divided into 3 panes (left, right and bottom). In one of them is a window derived from CSizingTabCtrlBar. This has 3 tab views assigned to it. One of these tab views uses a CTreeCtrlDnD object and so looks like an explorer window. The problem was two fold: 1) If I opened a modal dialog that happened to obscure part of this window and then closed it again, the part of the underlying window that was hidden was not redrawn. It would be redrawn if I toggled the view however. 2) If I minimize / maximize the application then the explorer view is greyed out. This occurs no matter what view (of the 3 tabbed views) is active at the time that the application is minimized. I.e. so even if the the "explorer" view is not active and hidden under one of the other tabbed views, if I minimize and maximize the application then select the "exploer" view it is greyed out. Again, if I cycle the views using the tabs it is redrawn correctly.(Also, I sometimes need to cycle views twice). Through using the debugger I know that the relevant OnDraw and OnPaint messages are being called and so I guess the WM_PAINT message is being sent as expected. (I tried using Spy++ to confrim message is being sent but it keeps crashing) I have solved problem (1) by overriding the base class (CFormView) OnDraw method and calling UpdateWindow as shown below:

    void CWorkspaceWindowTab2View::OnDraw(CDC *pDC)
    {
    this->UpdateWindow();
    CView::OnDraw(pDC);

    }

    However, even though the program is entering this OnDraw method when I minimize/maximize the application the explorer view (CWorkspaceWindowTab2View) is not being redrawn. Any ideas? Thanks in advance Rich

    modified on Tuesday, June 10, 2008 6:36 AM

    R C J M 4 Replies Last reply
    0
    • K kildareflare

      Hello I've searched google and MSDN but cannot search the forums here yet as it keeps timing out. I've managed to improve my problem butnot completely resolve it. My application is divided into 3 panes (left, right and bottom). In one of them is a window derived from CSizingTabCtrlBar. This has 3 tab views assigned to it. One of these tab views uses a CTreeCtrlDnD object and so looks like an explorer window. The problem was two fold: 1) If I opened a modal dialog that happened to obscure part of this window and then closed it again, the part of the underlying window that was hidden was not redrawn. It would be redrawn if I toggled the view however. 2) If I minimize / maximize the application then the explorer view is greyed out. This occurs no matter what view (of the 3 tabbed views) is active at the time that the application is minimized. I.e. so even if the the "explorer" view is not active and hidden under one of the other tabbed views, if I minimize and maximize the application then select the "exploer" view it is greyed out. Again, if I cycle the views using the tabs it is redrawn correctly.(Also, I sometimes need to cycle views twice). Through using the debugger I know that the relevant OnDraw and OnPaint messages are being called and so I guess the WM_PAINT message is being sent as expected. (I tried using Spy++ to confrim message is being sent but it keeps crashing) I have solved problem (1) by overriding the base class (CFormView) OnDraw method and calling UpdateWindow as shown below:

      void CWorkspaceWindowTab2View::OnDraw(CDC *pDC)
      {
      this->UpdateWindow();
      CView::OnDraw(pDC);

      }

      However, even though the program is entering this OnDraw method when I minimize/maximize the application the explorer view (CWorkspaceWindowTab2View) is not being redrawn. Any ideas? Thanks in advance Rich

      modified on Tuesday, June 10, 2008 6:36 AM

      R Offline
      R Offline
      Rage
      wrote on last edited by
      #2

      kildareflare wrote:

      the part of the underlying window that was hidden was not redrawn

      Maybe you could send a Redraw message to that view when closing your dialog ?

      kildareflare wrote:

      the explorer view is greyed out

      Do you mean "disabled", or simply filled with grey color ?

      K 1 Reply Last reply
      0
      • K kildareflare

        Hello I've searched google and MSDN but cannot search the forums here yet as it keeps timing out. I've managed to improve my problem butnot completely resolve it. My application is divided into 3 panes (left, right and bottom). In one of them is a window derived from CSizingTabCtrlBar. This has 3 tab views assigned to it. One of these tab views uses a CTreeCtrlDnD object and so looks like an explorer window. The problem was two fold: 1) If I opened a modal dialog that happened to obscure part of this window and then closed it again, the part of the underlying window that was hidden was not redrawn. It would be redrawn if I toggled the view however. 2) If I minimize / maximize the application then the explorer view is greyed out. This occurs no matter what view (of the 3 tabbed views) is active at the time that the application is minimized. I.e. so even if the the "explorer" view is not active and hidden under one of the other tabbed views, if I minimize and maximize the application then select the "exploer" view it is greyed out. Again, if I cycle the views using the tabs it is redrawn correctly.(Also, I sometimes need to cycle views twice). Through using the debugger I know that the relevant OnDraw and OnPaint messages are being called and so I guess the WM_PAINT message is being sent as expected. (I tried using Spy++ to confrim message is being sent but it keeps crashing) I have solved problem (1) by overriding the base class (CFormView) OnDraw method and calling UpdateWindow as shown below:

        void CWorkspaceWindowTab2View::OnDraw(CDC *pDC)
        {
        this->UpdateWindow();
        CView::OnDraw(pDC);

        }

        However, even though the program is entering this OnDraw method when I minimize/maximize the application the explorer view (CWorkspaceWindowTab2View) is not being redrawn. Any ideas? Thanks in advance Rich

        modified on Tuesday, June 10, 2008 6:36 AM

        C Offline
        C Offline
        Cedric Moonen
        wrote on last edited by
        #3

        It looks like the drawing stuff is not done in the OnPaint method but somewhere else in the code. It means that the redrawing is not handled properly. Did you write the code yourself ?

        Cédric Moonen Software developer
        Charting control [v1.4]

        K 1 Reply Last reply
        0
        • R Rage

          kildareflare wrote:

          the part of the underlying window that was hidden was not redrawn

          Maybe you could send a Redraw message to that view when closing your dialog ?

          kildareflare wrote:

          the explorer view is greyed out

          Do you mean "disabled", or simply filled with grey color ?

          K Offline
          K Offline
          kildareflare
          wrote on last edited by
          #4

          Hello, I mean that the view is filled with grey colour. Occasionally, one the root item of the tree will also be displayed, with everything else grey. As it happens there is no longer a problem when closing the dialog. that was fixed when i overode the base class OnDraw function. The problem that remains is when the application is minimized and then maximized again....

          1 Reply Last reply
          0
          • C Cedric Moonen

            It looks like the drawing stuff is not done in the OnPaint method but somewhere else in the code. It means that the redrawing is not handled properly. Did you write the code yourself ?

            Cédric Moonen Software developer
            Charting control [v1.4]

            K Offline
            K Offline
            kildareflare
            wrote on last edited by
            #5

            Hi Cedric I wrote some of the code myself, some i inherited and the rest is standard MFC stuff. The application only contains dialogs and buttons etc there are no user defined images etc that required customised drawing methods. With the exception of the problem listed the default base class methods (CView) handle the redrawing of all items correctly. while you may be correct that OnPaint is not doing the drawing whatever is doing it is part of the MFC and so one would imagine that would work OK, right? I initially thought the problem was that for some reason the window was not receiving a WM_PAINT message. However since the program allways breaks at the OnDraw methodit must be.... I have completed some more testing and have the following to add... When the app is first opened this problem does not occur. If i then do anything that causes the explorer view ot refresh (Correctly) add an item to the explorer view for example. The problem is now present until the application is restarted...

            1 Reply Last reply
            0
            • K kildareflare

              Hello I've searched google and MSDN but cannot search the forums here yet as it keeps timing out. I've managed to improve my problem butnot completely resolve it. My application is divided into 3 panes (left, right and bottom). In one of them is a window derived from CSizingTabCtrlBar. This has 3 tab views assigned to it. One of these tab views uses a CTreeCtrlDnD object and so looks like an explorer window. The problem was two fold: 1) If I opened a modal dialog that happened to obscure part of this window and then closed it again, the part of the underlying window that was hidden was not redrawn. It would be redrawn if I toggled the view however. 2) If I minimize / maximize the application then the explorer view is greyed out. This occurs no matter what view (of the 3 tabbed views) is active at the time that the application is minimized. I.e. so even if the the "explorer" view is not active and hidden under one of the other tabbed views, if I minimize and maximize the application then select the "exploer" view it is greyed out. Again, if I cycle the views using the tabs it is redrawn correctly.(Also, I sometimes need to cycle views twice). Through using the debugger I know that the relevant OnDraw and OnPaint messages are being called and so I guess the WM_PAINT message is being sent as expected. (I tried using Spy++ to confrim message is being sent but it keeps crashing) I have solved problem (1) by overriding the base class (CFormView) OnDraw method and calling UpdateWindow as shown below:

              void CWorkspaceWindowTab2View::OnDraw(CDC *pDC)
              {
              this->UpdateWindow();
              CView::OnDraw(pDC);

              }

              However, even though the program is entering this OnDraw method when I minimize/maximize the application the explorer view (CWorkspaceWindowTab2View) is not being redrawn. Any ideas? Thanks in advance Rich

              modified on Tuesday, June 10, 2008 6:36 AM

              J Offline
              J Offline
              Jagdish V Bhimbha
              wrote on last edited by
              #6

              Take help of UpdateData(FALSE); I think thats only missing in ur code... Have good luck...! :)

              Jagdish Bhimbha S/W Engineer

              1 Reply Last reply
              0
              • K kildareflare

                Hello I've searched google and MSDN but cannot search the forums here yet as it keeps timing out. I've managed to improve my problem butnot completely resolve it. My application is divided into 3 panes (left, right and bottom). In one of them is a window derived from CSizingTabCtrlBar. This has 3 tab views assigned to it. One of these tab views uses a CTreeCtrlDnD object and so looks like an explorer window. The problem was two fold: 1) If I opened a modal dialog that happened to obscure part of this window and then closed it again, the part of the underlying window that was hidden was not redrawn. It would be redrawn if I toggled the view however. 2) If I minimize / maximize the application then the explorer view is greyed out. This occurs no matter what view (of the 3 tabbed views) is active at the time that the application is minimized. I.e. so even if the the "explorer" view is not active and hidden under one of the other tabbed views, if I minimize and maximize the application then select the "exploer" view it is greyed out. Again, if I cycle the views using the tabs it is redrawn correctly.(Also, I sometimes need to cycle views twice). Through using the debugger I know that the relevant OnDraw and OnPaint messages are being called and so I guess the WM_PAINT message is being sent as expected. (I tried using Spy++ to confrim message is being sent but it keeps crashing) I have solved problem (1) by overriding the base class (CFormView) OnDraw method and calling UpdateWindow as shown below:

                void CWorkspaceWindowTab2View::OnDraw(CDC *pDC)
                {
                this->UpdateWindow();
                CView::OnDraw(pDC);

                }

                However, even though the program is entering this OnDraw method when I minimize/maximize the application the explorer view (CWorkspaceWindowTab2View) is not being redrawn. Any ideas? Thanks in advance Rich

                modified on Tuesday, June 10, 2008 6:36 AM

                M Offline
                M Offline
                Mark Salsbery
                wrote on last edited by
                #7

                kildareflare wrote:

                I have solved problem (1) by overriding the base class (CFormView) OnDraw method and calling UpdateWindow as shown below:

                This shouldn't fix anything. OnDraw() is called for every WM_PAINT message so calling UpdateWindow() to force a WM_PAINT message from the WM_PAINT message handler is just wrong. If you are using both WM_PAINT handlers and OnDraw() in your CView-derived classes, then make sure you're not doing recursive stuff like this. It's much simpler to use just the OnDraw() method for your painting. If you must use your own WM_PAINT handler, then you can eliminate the OnDraw() virtual call if you need to. See the source code for CView::OnPaint() for details. Mark

                Mark Salsbery Microsoft MVP - Visual C++ :java:

                K 1 Reply Last reply
                0
                • M Mark Salsbery

                  kildareflare wrote:

                  I have solved problem (1) by overriding the base class (CFormView) OnDraw method and calling UpdateWindow as shown below:

                  This shouldn't fix anything. OnDraw() is called for every WM_PAINT message so calling UpdateWindow() to force a WM_PAINT message from the WM_PAINT message handler is just wrong. If you are using both WM_PAINT handlers and OnDraw() in your CView-derived classes, then make sure you're not doing recursive stuff like this. It's much simpler to use just the OnDraw() method for your painting. If you must use your own WM_PAINT handler, then you can eliminate the OnDraw() virtual call if you need to. See the source code for CView::OnPaint() for details. Mark

                  Mark Salsbery Microsoft MVP - Visual C++ :java:

                  K Offline
                  K Offline
                  kildareflare
                  wrote on last edited by
                  #8

                  Hello All I've found the solution to the problem, thoug not sure exactly why. Since the "explorer" view allways drew itself correctly when the application is first started and also when resizing the view I guessed that one difference is that the problem occurs when trying to update the view while it is not in focus - i.e. minimized. Figuring that there must be something different in the two scenarios I checked the InitialiseTreeCtrl method. The only extra code completed here that was not called when the window was minimized was a call to destroy and then recreate the control. I found that I needed to call the above function prior to calling setFocus() and UpdateWindow(). This appears to resolve the problem. I have moved the calls to SetFocus and UpdateWindow from the overriden OnDraw method to my mainFrames Move method, since this is called when the window is minimized/maximized. So the code required to fix this is below: workspacewindow is derived from CSizingTabCtrlBar After getting a pointer to the view on which the explorer window lies I have to: 1) Initialize the tree (destroy it and creat again, resize as appropriate and assign image list) 2) Update the tree (insert items from list, expand and ensure visibile) 3) Invalidate ctrl 4) Give the view and so control focus 5) Update the window

                  void CMainFrame::OnMove(int x, int y)
                  {
                  ///.......///

                  CWorkspaceWindowTab2View* pWorkspaceTab2View = (CWorkspaceWindowTab2View*)((CMainFrame*)theApp.m_pMainWnd)->m_pWorkspaceWindow->GetView(EXPLORER_VIEW);

                  pWorkspaceTab2View->InitializeLoopBrowserTree(); 
                  pWorkspaceTab2View->UpdateLoopBrowserTree();
                  pWorkspaceTab2View->GetDlgItem(IDC\_LOOPS\_TREE)->Invalidate(TRUE);
                  pWorkspaceTab2View->SetFocus();
                  pWorkspaceTab2View->UpdateWindow();
                  

                  }

                  Although, I have just noticed that occasionly when changing views using the tabcontrol this view is not updated. I can "fix" this also by placing a call to the InitialiseTreeCtrl method in the CSizingTabCtrlBar::SetActiveView method, however this of course breaks a few rules...any other suggetions...? Thanks Rich

                  modified on Wednesday, June 11, 2008 8:29 AM

                  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