PDA

View Full Version : refreshing windows



coda
10-22-2003, 04:38 PM
I was wondering why windows doesn't automatically refresh my SDI view? I had a dialog in front of my view and when i moved or minimized the dialog, the graphic in the SDI view becomes obsured by a white patch, how do i refresh it again?

Relic
10-23-2003, 02:23 AM
With SDI you mean single document interface?
Then put your OpenGL drawing code into the WM_PAINT message handler where it belongs and you'll be done.
Windows automatically sends repaint messages when window areas are exposed.
Be careful, you must not assume that regions beneath other windows are still correct in any of the OpenGL buffers associated with that area, like front, back, depth, stencil. All have to be repainted, a SwapBuffers is not enough.

coda
10-23-2003, 05:06 PM
yup I am using single document interface... I actually put my Opengl coding in my didalog.cpp because i need user inputs from that dialog and i have several dialogs too for drawing different things... u mean windows will only automatically re-display my graphics if i put my drawing code in the View class OnPaint handler? is there any other way whereby i can re-display the grphics while keeping my codes in the dialog.cpp?

coda
10-23-2003, 05:13 PM
i tried coding the drawing into my dialog's OnPaint's handler but the white patch still there.

Deiussum
10-24-2003, 04:22 AM
You put it in the OnPaint of the dialog? The one that is doing the covering of the SDI window? How do you expect that to help you? It's the OnPaint of the SDI window that will get called when it needs to be re-painted. Put your code in there.

All the drawing should be done in the OnPaint call of the method that is actually displaying the OpenGL. Everything else you have, shouldn't be doing the drawing itself, but instead should be setting state variables to let the drawing method know what and how it should be drawn.

[This message has been edited by Deiussum (edited 10-24-2003).]

coda
10-24-2003, 02:49 PM
okie i get your point, but because i need the user inputs from the dialog in order to draw say a rectangle, then since i am coding into the on_paint of the SDI window, how to I ensure that the image will only appear after i input my dimensions and close the dialog through the OK button? that is, i not sure where to call the on_paint to draw only when i have close the dialog...

Deiussum
10-27-2003, 04:19 AM
You should be keeping a list of some sort of everything you are drawing. Then in the OK handler of the dialog to create a rectangle, you would add a new rectangle to that list and invalidate the main SDI window so that a WM_PAINT is generated. You SHOULD NOT call the OnPaint method directly.