I have an application which allows users to create documents that could potentially contain a lot of fonts, brushes and pens. In order to keep GDI handle usage to a minimum I was planning to implement some form of shared GDI object pool (as many of the GDI objects used by these documents will be the same) but before I did I thought it worth asking if anyone here has come across anything similar before. I am using MFC FWIW.
asking if anyone here has come across anything similar before
Yes I have implemented and seen libraries for object pools. I believe they are fairly common. In fact there is C++ template based article for one here on code project which one finds with a simple Google search[^].
I derived my class from CListBox called CMyListBox. then I write the virtual function MeasureItem to change the height of items. In my main dialog CMyDialog, construct a CMyListBox object. CMyListBox m_ctlBox;
but it has no affect. The height doesn't change at all. But it executes fine.
Then I've tried comment the code m_ctlBox.ModifyStyle(0, LBS_OWNERDRAWFIXED); And in the resource editor, I change the property of the ListBox with OwnerDraw to OwnerDrawFixed, then I got compilation assertion error.
What do I miss? And Why do I get the assertion error?But I don't want to create the CMyListBox on the fly at all, cause If I create it on the fly, I can't adjust its position and size.
And in the book «Programming with MFC 2nd», I program as the book shows, it works fine. First, in the CMyListBox use the PreCreateWindowClass to add the style with LBS_OWNERDRAWFIXED OR LBS_OWNERDRAWVARIABLE. Second, in the virtual MeasureItem function to change the height. Third, But you should in the CMyDialog::OnInitDialog to create the CMyListBox on the fly, it should use CMyListBox.Create to create the ListBox, otherwise the CMyListBox::PreCreateWindowClass would not be called to initialize the style with LBS_OWNERDRAWFIXED.
Why is asking a legitimate question considered being bold?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
Last Visit: 31-Dec-99 19:00 Last Update: 16-Jan-17 10:44