Introduction
The idea for this article came from a query in the VC++ forum. I hope someone does find this useful.
How to use PSM_QUERYSIBLINGS
If you want to know how to use the PSM_QUERYSIBLINGS message to send data between pages on a property sheet, the first step is to look at the CPropertyPage::QuerySiblings function.
LRESULT CPropertyPage::QuerySiblings(WPARAM wParam, LPARAM lParam)
{
ASSERT(::IsWindow(m_hWnd));
ASSERT(GetParent() != NULL);
return GetParent()->SendMessage(PSM_QUERYSIBLINGS, wParam, lParam);
}
You will see all it does is sends a PSM_QUERYSIBLINGS message to the parent CPropertySheet. The property sheet's default behavior is to relay the PSM_QUERYSIBLINGS message to all of its child pages. So for each page, you would set up a message map entry to catch the PSM_QUERYSIBLINGS message, and add the function to handle it.
BEGIN_MESSAGE_MAP(CMyPropertyPage, CPropertyPage)
ON_MESSAGE(PSM_QUERYSIBLINGS, OnQuerySiblings)
END_MESSAGE_MAP()
...
LRESULT CMyPropertyPage1::OnQuerySiblings(WPARAM wParam, LPARAM lParam)
{
return 0; }
If you want the property sheet to handle the message, you would set up the sheet's message map to also catch the PSM_QUERYSIBLINGS message. Just be sure to call Default() so that the default handler gets called.
LRESULT CMyPropertySheet::OnQuerySiblings(WPARAM wParam, LPARAM lParam)
{
return Default();
}
If you want to change the wParam and lParam values when your sheet handles the message, and pass the changed values onto the property pages, you will have to send the PSM_QUERYSIBLINGS message to each window yourself.
LRESULT CMyPropertySheet::OnQuerySiblings(WPARAM wParam, LPARAM lParam)
{
int nPages = GetPageCount();
LRESULT result = 0;
for (int page = 0; page < nPages && result == 0; ++page)
result = GetPage(page)->SendMessage(PSM_QUERYSIBLINGS, wParam, lParam);
return result;
}