# OpenGL OpenGL + Window controls

This topic is 4610 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello! I am trying to make a simple application using OpenGL and WinAPI. I've got a dialog form where the scene - together with some windows controls (edit box, button and a check box) - is displayed. Everything seems fine but after my dialog loses focus (i.e, it hides under other window), the windows controls are not redrawed when the dialog gets its focus back again. You can take a look and see what I mean : priv.ckp.pl/aero/window.png I guess that the problem should be solved somewhere around WM_PAINT message. For the time being, here is what I do after getting WM_PAINT message :
case WM_PAINT:
Render();   // just render GL scene (that's where SwapBuffers() is called)
return TRUE;

I'd be thankful if you could help me with this one! :)

##### Share on other sites
Im not an expert in using win32 forms. But I think u need to call this:

case WM_PAINT: // paint
render();
PAINTSTRUCT ps;
BeginPaint(hWnd, &ps);
EndPaint(hWnd, &ps);
break;

Hope that works for u!

##### Share on other sites
Thanks, Cacks! Actually it solves the problem I mentioned. Unfortunately, now it seems that I get WM_PAINT message _only_ when my dialog gets focus. This means that Render() function isn't continuously called each frame. Do you know what can I do about this? Maybe I should put Render() into a timer?

Plus, how can I correctly initialize PAINTSTRUCT ps ?

Great thanks!

##### Share on other sites
As I say, im not an expert, but I think that the WM_PAINT message is only meant to be sent on special occassions such as minimising & maximising & uncovering of the window, so put ur renderer in a timer within the main procedure.

typedef struct tagPAINTSTRUCT {
HDC hdc;
BOOL fErase;
RECT rcPaint;
BOOL fRestore;
BOOL fIncUpdate;
BYTE rgbReserved[16];
} PAINTSTRUCT;

Declared in Winuser.h

Which I think its included in windows.h

Got this from MSDN.

I presume it is initialised when creating a form, but Im not sure.

1. 1
2. 2
3. 3
4. 4
frob
15
5. 5

• 16
• 12
• 20
• 12
• 18
• ### Forum Statistics

• Total Topics
632162
• Total Posts
3004506

×