Windows flicking

Hello,

i have some elements in my window, and when i minimize and restore the windows, all my text fields, buttons and labels strarts to blink..

i've search and i found that i need to use WS_CLIPCHILDREN, but dont work..
my code :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
HBRUSH brush = CreateSolidBrush(RGB(199, 222, 234));
wcex.hbrBackground = CreatePatternBrush(LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BG)));
wcex.lpszMenuName = NULL;
wcex.lpszClassName = szWindowClass;
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
wcex.hIconSm =LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_ICON1));

1
2
3
4
5
6
7
8
9
10
11
HWND hWnd = CreateWindow(
		szWindowClass,
		szTitle,
		WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX ,
		CW_USEDEFAULT, CW_USEDEFAULT,
		390, 350,
		NULL,
		NULL,
		hInstance,
		NULL
		);

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
case WM_PAINT:
	hdc = BeginPaint(hWnd, &ps);
	codigoLabel = CreateWindow("STATIC", "Código:",
				WS_VISIBLE | WS_CHILD ,
				160, 90, 45, 16.5,
				hWnd, NULL, NULL, NULL);
	SendMessage(codigoLabel, WM_SETFONT, WPARAM(hFont), TRUE);

	codigoTextBox = CreateWindowEx(WS_EX_PALETTEWINDOW,
				TEXT("Edit"),
				NULL,
				WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT,
				160, 110, 200, 26,
				hWnd, NULL, NULL, NULL);
	SendMessage(codigoTextBox, WM_SETFONT, WPARAM(hFont), TRUE);
break;


what can i do for stop blinking?
You should create your child controls in WM_CREATE. The flicker comes probably because WM_PAINT is called quite frequently. Also you waste a lot of resources by creating the child windows over and over again. Since Windows paints the child controls you have nothing to do in WM_PAINT.
Thank you!

it works !

i change place all in WM_CREATE and the flickers stoped!

thank you!
Topic archived. No new replies allowed.