WS_EX_COMPOSITED calls unexpected WM_PAINT

Create a window with the WS_EX_COMPOSITED style:

hWnd = CreateWindowEx(WS_EX_COMPOSITED, szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); 

Set the cursor for the window:

 case WM_PAINT: OutputDebugStringA("WM_PAINT"); hdc = BeginPaint(hWnd, &ps); // TODO: Add any drawing code here... EndPaint(hWnd, &ps); break; case WM_SETFOCUS: ::DestroyCaret(); ::CreateCaret(hWnd, NULL, 2, 12); ::SetCaretPos(200, 200); ::ShowCaret(hWnd); break; case WM_KILLFOCUS: ::DestroyCaret(); break; case WM_CHAR: ::DestroyCaret(); ::CreateCaret(hWnd, NULL, 2, 12); ::SetCaretPos(200, 200); ::ShowCaret(hWnd); break; 

Launch the application and do nothing. they will be infinite WM_PAINT until they hide the carriage or destroy the carriage.

Spy ++ shows: every 0x118 (WM_SYSTIMER) that the carriage blinks, a WM_PAINT message follows.

The paint structure returned by BeginPaint,

WM_PAINT : invaliate rect width = 2, height = 12

which represents only the width and height of the carriage. In conclusion, WM_PAINT is for flashing a carriage.

But if I remove the WM_EX_COMPOSITED style from the additional styles for the window, there is no longer an infinite WM_PAINT.

Is this a windows error?

PS: Windows 7 64bit + visual studio 2012 test environments.

+4
source share
1 answer

The carriage is also considered a control. Do not use WS_EX_COMPOSITED for top-level windows. Or use it for a specific problem management.

Or ignore the WM_ERASEBACKGROUND in the WndProc control that has foreground content spanning the entire client area and the control flickers when resized.

+1
source

Source: https://habr.com/ru/post/1501596/


All Articles