Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating an array of brushes

Status
Not open for further replies.

FreonP

Programmer
Jul 11, 2023
1
0
0
US
thread116-23314

I think more context is needed for this tip. If you're returning a brush from an override of CDialog::OnCtlColor(), you don't want the CBrush object destroyed, do you? In my app, I create and destroy the CBrush objects along with the dialog box. In OnCtlColor(), I found that I couldn't create an array of CBrush objects, so I created a static array of pointers to the CBrush objects. I select the array element based on the control ID, then dereference it to get the brush.
 
The question was asked in 2000 when PCs didn't have a lot of memory. Nowadays, I'd create the resources at the start of the program and delete them at the end. Alternatively at the start of the dialog and delete them when the dialog terminates or pass them to the dialog when the dialog opens.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top