In the past few days, some of our readers have encountered a known bug when changing the background color of a Win32 API window. This problem occurs for several reasons. Now we will deal with them.
Approved: Fortect
I don’t use dialog in the morning, I use my own class which I actually saved, then I used the phone CreateWindow
to create it, I have a predefined red background color on the Caption:
WNDCLASSEX WC;wc.hbrBackground is equivalent to CreateSolidBrush (RGB (255, 0, 0));
But now I need to change the background color while executingOpinions, for example by pressing a button to change it to blue.
I tried using the SetBkColor ()
call in WM_PAINT
and proved that the WM_CTLCOLORDLG
brush can handle the returned PM, they don’t work.
37.1k
requested on 11 August 2010 during the 10:48 pm visit
2461
Isn’t The Answer You Want? Browse Other Questions Tagged C ++ Api Winapi Or Ask Your Own Question.
… Hardware draws the background for Windshield or attach window A chance to do this by sending for WM_ERASEBKGND message when The workload calls BeginPaint. When The request is being processed But the news calms down DefWindowProc, removes the setting background by dragging it from Pattern on brush background given by the window class …..
…… the app can WM_ERASEBKGND message though Classification background brush set. This is undoubtedly typical of applications that Allow this user to edit the window Specify color or pattern the window is given without influence other windows with class. In such In some cases, the corresponding request may not go through. the sale message in DefWindowProc. …..
So use the wm_erasebkgnd wParam from the post to get the DC and activate the background.
… Model draws the background Time lapse or give a window Ability to send a situation WM_ERASEBKGND message when a practical application calls BeginPaint. When Do not process the request at all Message, but send it DefWindowProc, percentRemoval fool Context by filling it in who has it Pattern with a foundation brush given by the window class …..
…… the app can WM_ERASEBKGND message though Background style brush set. This may be typical for applications that Activate the user to change the window Color or heritage swatch for window identified without influence other windows here in the classroom. In such Cases in which the request should not go through the DefWindowProc signal. …..
answered Aug 11 ’09 at 11:20
Approved: Fortect
Fortect is the world's most popular and effective PC repair tool. It is trusted by millions of people to keep their systems running fast, smooth, and error-free. With its simple user interface and powerful scanning engine, Fortect quickly finds and fixes a broad range of Windows problems - from system instability and security issues to memory management and performance bottlenecks.
60.8k
HBRUSH brush = CreateSolidBrush (RGB (0, 0, 255));SetClassLongPtr (hwnd, GCLP_HBRBACKGROUND, (LONG_PTR) brush);
2,785
replied on August 11, 2010 at 22:59 Moscow time.
2,873
When users register WNDCLASS, they provide reports on all windows of this class. So if you just want to change the color of the window, you have to take care of it yourself.
When it’s time to repaint the window, send a message WM_ERASEBKGND
to your wndproc. If you can’t handle it, DefWindowProc
will remove the client color box from the elegance of the window. But you can directly edit the match and paint the background (or pattern) any color you like.
answered on August 11 this year at 23:06.
41.7k
Speed up your computer's performance now with this simple download.