CFileDialog creates GDI objects and doesn't clean them up.



I've created a simple MFC dialog app <http://weatherley.net/noddy.zip>
which has a button that raises a common file dialog. The only code
change I've made from the devstudio generated boilerplate is:

void CNoddyDlg::OnButton1()
{
// TODO: Add your control notification handler code here
FileDialog dialog(TRUE);
dialog.DoModal();
}


Before raising the dialog the state of play with regards to GDI
Objects is:

DC 5
Brush 1
Bitmap 1
Font 1
--------
Total 8

Pushing the button and raising the file dialog:

DC 19
Brush 13
Bitmap 16
Font 16
Palette 2
Region 1
---------
Total 67

Closing the file dialog:

DC 15
Brush 11
Bitmap 11
Font 1
Region 1
----------
Total 39

Coming out of WinMain()

DC 15
Bitmap 11
Brush 11
Region 1
----------
Total 38


The extra bitmaps appear to be image lists and masks of folders and
the like - see <http://weatherley.net/pics/imagelist.jpg> for an
example. The questions are:

o Why doesn't the CFileDialog clean up after itself?
o Is it something I've forgotten to do or is this behaviour 'by
design'?
o Is there any way of dumping the CFileDialog related GDI objects?

Cheers
.