From: Nick Schultz on
Hi there, I'm developing an application that requires multiple OpenGL windows
within their own floating CDockablePane. I used examples from this article (
http://www.gamedev.net/reference/articles/article1358.asp) to create the
OpenGL classes, (I had to convert the main class from being a CView to a
CWnd, however) The CDockablePanes consist of a toolbar docked on the bottom
and OpenGL window taking up the rest of the Pane.

I am able to draw separate pictures in each window just fine. The problem I
have is that WM_ON_PAINT is constantly being called, sucking all processor
resources. (for painting a simple square) It's getting called even when each
window is still, not being overlapped by any other window.

Why is WM_ON_PAINT being called so much? Is there anyway to stop it? Also,
if you have any suggestions on using OpenGL windows, feel free to let me know.

Thanks,

Nick
From: Scott McPhillips [MVP] on
"Nick Schultz" <NickSchultz(a)discussions.microsoft.com> wrote in message
news:EC3B6CE2-8424-4F87-9962-163EEBE38107(a)microsoft.com...
> Hi there, I'm developing an application that requires multiple OpenGL
> windows
> within their own floating CDockablePane. I used examples from this
> article (
> http://www.gamedev.net/reference/articles/article1358.asp) to create the
> OpenGL classes, (I had to convert the main class from being a CView to a
> CWnd, however) The CDockablePanes consist of a toolbar docked on the
> bottom
> and OpenGL window taking up the rest of the Pane.
>
> I am able to draw separate pictures in each window just fine. The problem
> I
> have is that WM_ON_PAINT is constantly being called, sucking all processor
> resources. (for painting a simple square) It's getting called even when
> each
> window is still, not being overlapped by any other window.
>
> Why is WM_ON_PAINT being called so much? Is there anyway to stop it?
> Also,
> if you have any suggestions on using OpenGL windows, feel free to let me
> know.


This typically happens if you fail to use CPaintDC in your WM_PAINT message
handler. That class, and only that class, properly validates the window
after you have painted.

--
Scott McPhillips [VC++ MVP]

From: Nick Schultz on
Solved.

Fixed by adding:

ValidateRect(NULL);

To the end of my OnPaint() message handler.

Thanks for pointing me in the right direction!

Nick

"Scott McPhillips [MVP]" wrote:

> "Nick Schultz" <NickSchultz(a)discussions.microsoft.com> wrote in message
> news:EC3B6CE2-8424-4F87-9962-163EEBE38107(a)microsoft.com...
> > Hi there, I'm developing an application that requires multiple OpenGL
> > windows
> > within their own floating CDockablePane. I used examples from this
> > article (
> > http://www.gamedev.net/reference/articles/article1358.asp) to create the
> > OpenGL classes, (I had to convert the main class from being a CView to a
> > CWnd, however) The CDockablePanes consist of a toolbar docked on the
> > bottom
> > and OpenGL window taking up the rest of the Pane.
> >
> > I am able to draw separate pictures in each window just fine. The problem
> > I
> > have is that WM_ON_PAINT is constantly being called, sucking all processor
> > resources. (for painting a simple square) It's getting called even when
> > each
> > window is still, not being overlapped by any other window.
> >
> > Why is WM_ON_PAINT being called so much? Is there anyway to stop it?
> > Also,
> > if you have any suggestions on using OpenGL windows, feel free to let me
> > know.
>
>
> This typically happens if you fail to use CPaintDC in your WM_PAINT message
> handler. That class, and only that class, properly validates the window
> after you have painted.
>
> --
> Scott McPhillips [VC++ MVP]
>
>