Vista problem with two programms and one window

I have a dialog based MFC application written with C++. It can open windows with empty OpenGL context. Now I want to draw something in this context with another application. Therefore I save the ID of the opened window and give it to the second application. After clicking on “Refresh”-button in second application the OpenGL commandos draw a Rectangle on the whole window. It works under XP and Vista.
The problems comes with Vista after resizing the window. If I resize the window and click “Refresh” second time, the OpenGl context stays in the start size.
After clicking “Refresh first time”:
After resize+“refresh”

On clicking Refresh this code runs:

RECT rcCtl;
::GetClientRect((HWND)m_windowkeyattach, &rcCtl);    

int height=rcCtl.bottom, width=rcCtl.right;

glClearColor( 0.0, 0.0, 0.0, 0.0 );

glViewport( 0, 0, width,height );
glMatrixMode( GL_PROJECTION );

glOrtho( -1,1, -1,1, -1, 1);
glMatrixMode( GL_MODELVIEW );

glBegin( GL_QUADS );

glColor3f(1.0, 0.0, 0.0);  
glVertex3f(-1.0, -1.0, 0.0);

glColor3f(0.0, 1.0, 0.0);
glVertex3f(-1.0, 1.0, 0.0);

glColor3f(0.0, 0.0, 1.0);
glVertex3f(1.0, 1.0, 0.0);
glColor3f(0.0, 0.0, 1.0);
glVertex3f(1.0, -1.0, 0.0);

SwapBuffers( hdc);

This “Feature” vanish if I turn PFD_DOUBLEBUFFER in pixel format off. But PFD_DOUBLEBUFFER is necessary for my application.
Knows somebody a solution for my problem? I use NVIDIA Quadro FX570 with newest driver and Vista 32Bit.
(sorry for my bad English)

I do not believe that window sharing is actually a legal practice on win32, as windows are owned by an application (please correct me if you are wrong). So, in my opinion you are used undocumented features and shouldn’t expect this working right.

why not one program with two windows?

I dont’t know if it’s a legal practice, but in my projekt I use this feature.

I use this feature in larger projekt and I can’t make it with one program and two windows without big effort.

Does somebody know a solution for my problem?


I’m surprised that you’re able to draw onto the other application’s window at all. But in any case, did you call glViewport() in response to the window resize? Otherwise it’ll just keep using the original viewport size.

Thank you for your answer Humus. Yes, I called glViewport(), but it did not help.


This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.