Question : Disable edit box on PropertyPage from main window

Hi,
I have a dialog with 2 radio buttons and a one propertysheet with 3 tabs (propertypages).
By default:
Radio button 1 is selected and tab1 is displayed and one edit box is disabled on that tab
At runtime: (I want)
Onselect of Radio button 2, I want to enable the edit box.
I have created a variable for edit box on the propertypage:
private:
CEdit m_EditCaptureImgName;
//do data exchage has
DDX_Control(pDX, IDC_EDIT_CONFIG_WINPE_IMG_NAME, m_EditCaptureImgName);

I have a function in the property-derived class as
EnableEditBox()
{GetDlgItem(IDC_EDIT_CONFIG_WINPE_IMG_NAME)->EnableWindow(TRUE);}

I am calling this function onclick of the radio button2, but it gives me debug assert failed.
Obviously it is not able to find the control since the value of m_EditCaptureImgName = 0x00000000.
I am missing a step here, but can someone tell me which?

Answer : Disable edit box on PropertyPage from main window

I had to change the flags for your CPropertySheet Create function, but otherwise, this worked OK.  It appears to be a perfectly valid way to put a set of propertypages onto a standard dialog box.

See the DoEnabling() function.  I usally end up with one of these for every dialog box and property page.  Basically, it looks at the current settings and decides which controls to enable or diable based on what it finds.

-- Dan

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
//-------------------- sheet constructor
CMySheet::CMySheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
	:CPropertySheet(pszCaption, pParentWnd, iSelectPage)
{
	AddPage( &m_cMyPg1 );
	AddPage( &m_cMyPg2 );
}
 
//-------------------- sheet initialization
BOOL CMySheet::OnInitDialog() 
{
	BOOL bResult = CPropertySheet::OnInitDialog();
	MoveWindow(4,75,360,450,TRUE);
   	return bResult;
}
 
 
//------- intialize the parent dialog box
 
BOOL CD50Dlg::OnInitDialog()
{
	CDialog::OnInitDialog();
	
	m_pSheet= new CMySheet("PropSheet", this);      
	// m_pSheet->Create(this,WS_CHILD | WS_VISIBLE,WS_EX_CONTROLPARENT);
	m_pSheet->Create(this,WS_CHILD | WS_VISIBLE ); // <<<<< changed
	
	return TRUE;
}
//------- button handling in parent dialog box
void CD50Dlg::OnRadio2()  { DoEnabling(); }
void CD50Dlg::OnRadio1()  { DoEnabling(); }
 
void CD50Dlg::DoEnabling() 
{
	BOOL fEnableEdit= TRUE;
	CButton* pRb1= (CButton*)GetDlgItem( IDC_RADIO1 );
	CButton* pRb2= (CButton*)GetDlgItem( IDC_RADIO2 );
	if ( pRb1->GetCheck()==1 ) {  // button 1 is selected, disable 
		fEnableEdit= FALSE;
	}
	if ( pRb2->GetCheck()==1 ) {  // button 2 is selected, enable 
		fEnableEdit= TRUE;
	}
	CMyPg1* pPg1= (CMyPg1*)m_pSheet->GetPage(0);
	pPg1->m_ctlEditFileName.EnableWindow( fEnableEdit );
}
Random Solutions  
 
programming4us programming4us