Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing window background colour

Tags:

c++

winapi

In the winAPI, how do I change the window background colour?

For example,

wc.hbrBackground = ....;

is for setting the window background initially, but how do I change it there after?

Thanks.

like image 363
Alexander Rafferty Avatar asked Oct 12 '25 07:10

Alexander Rafferty


1 Answers

Use the SetClassLongPtr function with the GCLP_HBRBACKGROUND argument:

SetClassLongPtr(windowHandle, GCLP_HBRBACKGROUND, brushHandle);

http://msdn.microsoft.com/en-us/library/ms633589%28VS.85%29.aspx

like image 169
Benjamin Lindley Avatar answered Oct 13 '25 22:10

Benjamin Lindley