Property sheet data validation 
Author Message
 Property sheet data validation

I'm trying to validate the input data in a property sheet when the
user clicks OK. I'd like to keep the property sheet open if the data
is invalid.  I can not get the property sheet to stay open.  I've
tried SetWindowLong and it appears to be failing (return value is
zero).  I've exhausted all my resources and have spent many hours
trying to get this to work.  Please help, my boss is going to kill me.
 The following is my code.  CPage1 is my property page.

BOOL CPage1::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
HWND hwndDlg;
HWND hWnd;
NMHDR* nmhdr = (NMHDR*)lParam;
        switch(nmhdr->code){
        case PSN_KILLACTIVE:
                hwndDlg = GetSafeHwnd();
                hWnd = (HWND)::GetParent(hwndDlg);
                long temp1;
                SetLastError(0); //resets error for SetWindowLong
return value
                temp1 =
SetWindowLong(hwndDlg,DWL_MSGRESULT,PSNRET_INVALID_NOCHANGEPAGE);
                //I also tried all of the following and none work.
                //SetWindowLong(hwndDlg,DWL_MSGRESULT,PSNRET_INVALID);
                //SetWindowLong(hwndDlg,DWL_MSGRESULT,true);
                //SetWindowLong(hWnd,DWL_MSGRESULT,PSNRET_INVALID_NOCHANGEPAGE);
                //SetWindowLong(hWnd,DWL_MSGRESULT,PSNRET_INVALID);
                //SetWindowLong(hWnd,DWL_MSGRESULT,true);
        } return true;

Quote:
}



Fri, 29 Oct 2004 18:42:16 GMT  
 Property sheet data validation
Hi Ed!



Quote:
> I'm trying to validate the input data in a property sheet when the
> user clicks OK. I'd like to keep the property sheet open if the data
> is invalid.  I can not get the property sheet to stay open.  I've
> tried SetWindowLong and it appears to be failing (return value is
> zero).  I've exhausted all my resources and have spent many hours
> trying to get this to work.  Please help, my boss is going to kill me.
>  The following is my code.  CPage1 is my property page.

Maybe you want to override OnCommand in your sheet

BOOL CMySheet::OnCommand(WPARAM wParam, LPARAM lParam)
{
 switch (wParam)
 {
 case IDOK:
 if(m_Page1.Parameter != OK_FOR_ME) return TRUE;
 }

 return CPropertySheet::OnCommand(wParam, lParam);

Quote:
}

HTH
Cheerio, Carsten


Fri, 29 Oct 2004 19:40:10 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Property Sheet : Exchange data between property pages

2. Property Sheet within a Property Sheet

3. Property sheet from property sheet

4. Q: Property sheet within a property sheet

5. Entering data in property sheet

6. Accessing CString type data in Property Sheet

7. MFC data exchange and property sheets

8. Saving data on window close - property sheet in formview

9. Data Validation of data inside a text file

10. Property Sheet and Property pages in ATL

11. How to disable property page on property sheet.

12. Property sheet in a property page

 

 
Powered by phpBB® Forum Software