window doesn't get redrawn
-
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.
-
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.
Invalidate()
(optionally followed byUpdateWindow()
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 -
Invalidate()
(optionally followed byUpdateWindow()
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.comIt 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.
-
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.
Replace
RedrawWindow()
withInvalidate()
. Add aTRACE()
statement just before the call toInvalidate()
to ensure the case is executing. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com