Microsoft KB Archive/304290

= PRB: MFC Property Sheets Close When Using Transcriber for Pocket PC =

Article ID: 304290

Article Last Modified on 7/27/2004

-

APPLIES TO


 * Microsoft eMbedded Visual C++ 4.0
 * Microsoft Windows CE Palm-size PC 2.01 software

-



This article was previously published under Q304290



SYMPTOMS
When you are using Microsoft Transcriber on a Pocket PC, a Microsoft Foundation Classes (MFC)-implemented property sheet dialog box disappears abruptly when you lift the stylus from the touch screen.



CAUSE
Modal property sheet dialog boxes in MFC are implemented through the use of a modeless dialog box and continual checking whether the active property page is NULL through the use of the PSM_GETCURRENTPAGEHWND message in the ContinueModal method. As soon as this message returns NULL, MFC assumes the user has clicked the OK button, and MFC closes the property sheets by returning FALSE from ContinueModal. However, lifting the stylus from the screen when using Microsoft Transcriber immediately causes the PSM_GETCURRENTPAGEHWND to return NULL.



RESOLUTION
To work around the problem override the ContinueModal method for the CPropertySheet-derived class. Instead of checking if the active page window handle has become NULL, check a custom implemented flag. The flag can be set by the OnOK method of the first PropertyPage. Clear this flag during the construction of the CPropertySheet-derived class.



MORE INFORMATION
The following code provides a brief example of the prescribed resolution. CPropSheet::CPropSheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage) :CPropertySheet(nIDCaption, pParentWnd, iSelectPage), uLastmsg(0) {   m_bOKToClose = FALSE; }

BOOL CPropSheet::ContinueModal {   // TODO: Add your specialized code here and/or call the base class if (!CWnd::ContinueModal) return FALSE;

if (m_bOKToClose) // means the OK button was pressed return FALSE;

return TRUE;

}

void CPropPage1::OnOK {   // TODO: Add your specialized code here and/or call the base class

// let the CPropSheet::ContinueModal function know it's ok to close CPropSheet *pSheet = (CPropSheet *)GetParent; pSheet->m_bOKToClose = TRUE;

CPropertyPage::OnOK; }

It is not necessary set the m_bOKToClose flag in the OnOK handler of each of the property pages. If OK is clicked while the second property page is displayed on top, OnOK is still called for the first property page and subsequent OnOK handlers are called before ContinueModal is called.

