CLabelControl problem
-
Hi all, Cant we hide a CLabelControl after declaring a variable..??? I am getting a run time error for this.
Test.h
CLabelControl m_Test;Test.cpp
DDX_Control(pDX, IDC_LABEL_TEST, m_Test);BOOL CExampleDlg::OnInitDialog()
{
CLabelControl* lTest;
lTest=(CLabelControl*)GetDlgItem(IDC_LABEL_TEST);
lTest->ShowWindow(SW_HIDE);
return true;
}If i comment
//CLabelControl m_Test; in Test.h
//DDX_Control(pDX, IDC_LABEL_TEST, m_Test); in Test.ppThen it runs without any error.
Can anyone have any idea Thanks in Advance Sharan
-
Hi all, Cant we hide a CLabelControl after declaring a variable..??? I am getting a run time error for this.
Test.h
CLabelControl m_Test;Test.cpp
DDX_Control(pDX, IDC_LABEL_TEST, m_Test);BOOL CExampleDlg::OnInitDialog()
{
CLabelControl* lTest;
lTest=(CLabelControl*)GetDlgItem(IDC_LABEL_TEST);
lTest->ShowWindow(SW_HIDE);
return true;
}If i comment
//CLabelControl m_Test; in Test.h
//DDX_Control(pDX, IDC_LABEL_TEST, m_Test); in Test.ppThen it runs without any error.
Can anyone have any idea Thanks in Advance Sharan
Your label control does not exist at the point you are trying to hide it. You need to call CDialog::OnInitDialog in your OnInitDialog method before the control exists.
BOOL CExampleDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CLabelControl* lTest;
lTest=(CLabelControl*)GetDlgItem(IDC_LABEL_TEST);
lTest->ShowWindow(SW_HIDE);
return true;
}Hope that helps.
Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193