Mihai Vilcu
Mihai Vilcu

Reputation: 1967

win32 buttons keep flashing

I made a small game in win32 c++ that works fine but i have a small problem with some buttons flashing. I'm guessing that it has something to do with the fact that i'm sending WN_PAINT very often.

InvalidateRect(hwnd, NULL, false);
UpdateWindow(hwnd);

I made the buttons with CreateWindow() like this

CreateWindow(TEXT("button"),  TEXT(BTN_SAVE), WS_VISIBLE | WS_CHILD, 
            client.right - offset[1] - 170, client.bottom - offset[3], 
            80, 25, hwnd, (HMENU)ID_BTN_SAVE, NULL, NULL);

Has anybody had this problem ? Is there any way i can fix it ?

Upvotes: 1

Views: 1092

Answers (1)

Alex F
Alex F

Reputation: 43311

Add WS_CLIPCHILDREN style to the parent window.

WS_CLIPCHILDREN

Excludes the area occupied by child windows when drawing occurs within the parent window. This style is used when creating the parent window.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms632600%28v=vs.85%29.aspx

Upvotes: 7

Related Questions