QA: Why a property page with a date time picker cannot be created?

Joao Paulo Figueira (joao.fig@mail.telepac.pt), July 28, 2003.

Question

My property sheet does not display correctly when I add a date time picker control to one of the pages. Why? How can I solve this?

Answer

The date time picker control is one of the Windows Common Controls. Before you use one of these you have to initialize the subsystem using InitCommonControlsEx, that will register the new window classes for your application. Your property sheet (or page) is not showing up because one of the controls it uses has not been properly registered (the date time picker).

But isn't MFC supposed to do this for me?

It should, but it doesn't, so you have to do it by yourself. There are a lot of places where you can do it, especially in your application class OnInitInstance handler.

Here is some sample code you can include in your application's OnInitInstance:

// // Initialize the date time control // INITCOMMONCONTROLSEX icce; icce.dwSize = sizeof(icce); icce.dwICC = ICC_DATE_CLASSES; InitCommonControlsEx(&icce);

The same problem can happen with other common controls.

Related resources: