QA: How to use property sheets in full screen mode?

Lee Vanderlaan (lvanderlaan@gfs.com), October 18, 2001.

Question

How can I make full-screened property sheets in an application for the Pocket PC by using MFC?

Answer

For applications that use windows and dialog boxes, full screen mode is pretty much straight forward. In article Q266244 of the Microsoft Development Network Library full screen mode can be obtained following the methods described. However, the article does not cover property sheets, which is another form of an MFC dialog with tabbed pages.

If a property sheet is to be displayed to cover the entire screen, similar code to the dialog box is placed in the OnInitDialog handler of the property sheet. Since CPropertySheet does not inherit from CDialog the MFC framework for Pocket PC does not create an empty command bar that needs to be hidden. This also means the m_bFullScreen and m_pWndEmptyCB member variables do not apply. This is different from the sample code shown in the MSDN article. Although a command bar can be created by doing the following:

m_pWndEmptyCB = new CCeCommandBar; if (m_pWndEmptyCB != NULL) { ((CCeCommandBar*)m_pWndEmptyCB)->CreateEx(this); }

Where the m_pWndEmptyCB is a member variable of the property sheet derived class. This code should precede the call to the base class in the OnInitDialog handler. The sample code in the MSDN article can then be inserted as indicated in the OnInitDialog handler of the CMfctest2Dlg class. NOTE: The call to SetIcon is not necessary. Once the command bar is no longer used it must be cleaned up by first destroying the command bar window and then deleting the command bar instance.

The area of code that is different than the MSDN sample is in regards to the resizing of the window. The sample indicates the following:

// Resize the window over the taskbar area. #define MENU_HEIGHT 26 RECT rect; GetWindowRect(&rect); rect.top -= MENU_HEIGHT; MoveWindow(&rect, TRUE);

To resize the property sheet the tab control created by the MFC framework for property sheets must be resized instead. The sample code can then be replaced by the following:

#define MENU_HEIGHT 25 CTabCtrl* pTabCtrl; RECT rect; // Resize tab control tied to the property sheet. pTabCtrl = GetTabControl(); pTabCtrl->GetWindowRect(&rect); ScreenToClient(&rect); rect.bottom += MENU_HEIGHT; pTabCtrl->MoveWindow(&rect);

Sample

You can download a sample project (21 Kb).

References

See the following MSDN article regarding the sample code indicated in the previous section:
Q266244: HOWTO: Create Full-Screen Applications for the PocketPC

You can also read more about different aspects of full screen programming like activization, SIP, etc at:
Using SHFullScreen for writing full screen applications