Click here to Skip to main content
15,892,517 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am trying to change dialog background color by changing brush using SetClassLongPtr in MFC.

Its not working.

Where do i put the call so that it will work?

Thanks,
Vaibhav.
Posted

As the MSDN Help[^]indicates:

'Use the SetClassLongPtr function with care. For example, it is possible to change the background color for a class by using SetClassLongPtr, but this change does not immediately repaint all windows belonging to the class. '


So I would suggest performing this as part of your OnInitDialog() or calling and InvalidateRect() after you've called SetClassLongPtr()...
 
Share this answer
 
Hi,

I have coded like this:

OnInitDialog
{
    <pre>SetClassLongPtrW(GetSafeHwnd(), GCLP_HBRBACKGROUND, (LONG_PTR)GetStockObject(WHITE_BRUSH));

   CRect rect;
   GetWindowRect(&amp;rect);
   InvalidateRect(&amp;rect);

}

But Dialog's background color is not changed.

Suggest me way to use SetClassLongPtr to change background color.

Thanks,
Vaibhav.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900