Working with Active and Inactive Property Sheet Pages

A property sheet can have only one active page at a time. The active sheet is at the top of the overlapping stack of pages. A user activates a page by selecting its tab; an application uses the PSM_SETCURSEL message to activate a page. Before the subsequent active page is visible, the property sheet sends it the PSN_SETACTIVE notification message. The page should respond by initializing its control windows.

The property sheet determines whether to enable or disable the Help button for an active page by checking for the PSP_HASHELP style. If the page has this style, it supports the Help button. If the PSP_HASHELP style is not present, it disables the button. When a user taps the Help button, the active page receives the PSN_HELP notification message. The page should respond by displaying Help information.

When a user taps OK, the property sheet sends the PSN_KILLACTIVE notification message to the active page, giving it an opportunity to validate a user's changes. If the page determines that the changes are valid, it should call the SetWindowLong function to set the DWL_MSGRESULT value for the page to FALSE. In this case, the property sheet sends the PSN_APPLY notification message to each page, directing it to apply the new properties to the corresponding item. If the page determines that a user's changes are not valid, it should set DWL_MSGRESULT to TRUE and display a dialog box informing a user of the problem. The page remains active until it sets DWL_MSGRESULT to FALSE in response to a PSN_KILLACTIVE message.

The property sheet sends the PSN_RESET notification message to all pages when a user taps the Cancel button, indicating that it is about to destroy the property sheet.

Note To set the position of a property sheet window in an application, use the SetWindowPos function rather than the MoveWindow function. Call SetWindowPos in the dialog box procedure of the property page that will open first when a user activates a property sheet.