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. window doesn't get redrawn

window doesn't get redrawn

Scheduled Pinned Locked Moved C / C++ / MFC
graphicshelpgame-dev
4 Posts 2 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
    Kamis
    wrote on last edited by
    #1

    I've got quite weird problem. From the main dialog I create a modal dialog where I make some computations and display results using OpenGL. I set Timer and when I get WM_TIMER message I redraw this dialog's window using RedrawWindow(). The problem is one time I create this dialog it works fine from the begining to the end. But when I try to do it again it doesn't get visually redrawn at all. I've placed different checks in my code. They have shown that in this dialog's lifecycle OnPaint func succesfully gets entered numerous times where I perform all the drawing. But I don't see any result. The problem arises on Win9x only. In 2k/XP everything goes perfect. Note that I don't only test it on Win9x but compile it's own variant too. So I need your help.

    R 1 Reply Last reply
    0
    • K Kamis

      I've got quite weird problem. From the main dialog I create a modal dialog where I make some computations and display results using OpenGL. I set Timer and when I get WM_TIMER message I redraw this dialog's window using RedrawWindow(). The problem is one time I create this dialog it works fine from the begining to the end. But when I try to do it again it doesn't get visually redrawn at all. I've placed different checks in my code. They have shown that in this dialog's lifecycle OnPaint func succesfully gets entered numerous times where I perform all the drawing. But I don't see any result. The problem arises on Win9x only. In 2k/XP everything goes perfect. Note that I don't only test it on Win9x but compile it's own variant too. So I need your help.

      R Offline
      R Offline
      Ravi Bhavnani
      wrote on last edited by
      #2

      Invalidate() (optionally followed by UpdateWindow() if you want the redraw to happen immediately) should cause a repaint. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

      K 1 Reply Last reply
      0
      • R Ravi Bhavnani

        Invalidate() (optionally followed by UpdateWindow() if you want the redraw to happen immediately) should cause a repaint. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

        K Offline
        K Offline
        Kamis
        wrote on last edited by
        #3

        It still doesn't work. Here's a scheme: // Main.cpp void CMainDialog::On_Visualize() // Create a modal dialog { ... OpenGL_Dialog my_gl; my_gl.DoModal(); ... } // OpenGL_Dialog.cpp BOOL OpenGL_Dialog::OnInitDialog() // Setting timer when creating dialog { CDialog::OnInitDialog(); ... draw_counter=0; SetTimer(1,10,NULL); } void OpenGL_Dialog::OnDestroy() // Kill timer when destroying { ... KillTimer(1); CDialog OnDestroy(); } void OpenGL_Dialog::OnPaint() { draw_counter++; // check CPaintDC dc(this); DrawGLScene2D; SwapBuffers(m_hgldc); } void OpenGL_Dialog::OnTimer(UINT nIDEvent) { switch(nIDEvent) { case 1: RedrawWindow(); break; ... } CDialog::OnTimer(nIDEvent); } void OpenGL_Dialog::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { switch (nChar) { case 32: char buf[10]; itoa(draw_counter,buf,10); AfxMessageBox(buf); break; ... } CDialog::OnKeyDown(nChar, nRepCnt, nFlags); } Something like this. I wouldn't actually have placed drawing handling on timer but I need to respond to user input and other stuff. So striking space during the dialog's lifecycle I get the number of redrawings and this number is growing all the time. But in most cases the screen stays blank and nothing is drawn.

        R 1 Reply Last reply
        0
        • K Kamis

          It still doesn't work. Here's a scheme: // Main.cpp void CMainDialog::On_Visualize() // Create a modal dialog { ... OpenGL_Dialog my_gl; my_gl.DoModal(); ... } // OpenGL_Dialog.cpp BOOL OpenGL_Dialog::OnInitDialog() // Setting timer when creating dialog { CDialog::OnInitDialog(); ... draw_counter=0; SetTimer(1,10,NULL); } void OpenGL_Dialog::OnDestroy() // Kill timer when destroying { ... KillTimer(1); CDialog OnDestroy(); } void OpenGL_Dialog::OnPaint() { draw_counter++; // check CPaintDC dc(this); DrawGLScene2D; SwapBuffers(m_hgldc); } void OpenGL_Dialog::OnTimer(UINT nIDEvent) { switch(nIDEvent) { case 1: RedrawWindow(); break; ... } CDialog::OnTimer(nIDEvent); } void OpenGL_Dialog::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { switch (nChar) { case 32: char buf[10]; itoa(draw_counter,buf,10); AfxMessageBox(buf); break; ... } CDialog::OnKeyDown(nChar, nRepCnt, nFlags); } Something like this. I wouldn't actually have placed drawing handling on timer but I need to respond to user input and other stuff. So striking space during the dialog's lifecycle I get the number of redrawings and this number is growing all the time. But in most cases the screen stays blank and nothing is drawn.

          R Offline
          R Offline
          Ravi Bhavnani
          wrote on last edited by
          #4

          Replace RedrawWindow() with Invalidate(). Add a TRACE() statement just before the call to Invalidate() to ensure the case is executing. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

          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