View Full Version : drawing an object on a dialog box
04-05-2000, 01:19 PM
I am trying to draw an object onto a dialog box in a win32 application. The dialog box has edit boxes and radio buttons and so forth.
If I use single buffering then I can get both the object and the dialog controls to display on the dialog box, but the object is screwed up.
If I use double buffering then the object is perfect, but I lose the dialog controls. Does anyone have experience or can provide some sort of help please.
I would create a child window on the dialog box use its Device Context to draw the object.
It sounds like you are drawing to the hWnd of the dialog box, which is incorrect. I think what happens is that the buttons and stuff are first drawn using GDI, then you are drawing with OpenGL and swapping buffers. The buffer swap causes the the entire dialog area to be replaced with your OpenGL scene.
One thing to do is to include in your dialog resource a picture window (assuming you are using the VC++ dialog editor). In your code, you can use one of the get dialog item functions (with the resource identifier of the picture window that you added) in order to get the hWnd of the picture box. Set up a OpenGL rendering context for this hWnd instead of the hWnd of you dialog box. Now, you can issue OpenGL calls and have the results end up in the picture box rather than the entire dialog. Make sure you keep you do a wglMakeCurrent call to make the picture box's rendering context current when you need to draw it and a wglMakeCurrent(NULL, NULL) to make no RC current when you are done drawing.
The only thing that you might see using this method is some flickering in the picture box. You might be able to fiddle with preventing the picture box from doing anything when the erase background message is received. This is what causes the flicker.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.