MrSandman666
Programmer
Hi guys.
It's been a while but still feels good to be back again. I'm slowly picking up programming again and right now I'm trying to get an MDI application together, which includes a few dialog bars. I'm an absolute newbie when it comes to MFC, so please be kind.
I know how to create and midify the Dialog Bar and I know how to process events from the controlls contained in it. However, till now I've had no luck whatsoever in actually accessing these controlls. I can not read the value of an edit controll or change it's properties. I can't populate a treeview, etc. Well, you get the idea.
I'm currently doing this:
void CMainFrame::OnRolldice()
{
CString Result;
CEdit* cNumberOfDice = (CEdit*)GetDlgItem(IDC_DR_DICE);
int len = cNumberOfDice->LineLength(cNumberOfDice->LineIndex(0));
cNumberOfDice->GetLine(0, Result.GetBuffer(len), len);
Result.ReleaseBuffer(len);
MessageBox(Result);
}
This works, except for the fact that GetDlgItem always returns NULL! Therefore, I get an access violation each time I run this code.
Any help? Please?
It's been a while but still feels good to be back again. I'm slowly picking up programming again and right now I'm trying to get an MDI application together, which includes a few dialog bars. I'm an absolute newbie when it comes to MFC, so please be kind.
I know how to create and midify the Dialog Bar and I know how to process events from the controlls contained in it. However, till now I've had no luck whatsoever in actually accessing these controlls. I can not read the value of an edit controll or change it's properties. I can't populate a treeview, etc. Well, you get the idea.
I'm currently doing this:
void CMainFrame::OnRolldice()
{
CString Result;
CEdit* cNumberOfDice = (CEdit*)GetDlgItem(IDC_DR_DICE);
int len = cNumberOfDice->LineLength(cNumberOfDice->LineIndex(0));
cNumberOfDice->GetLine(0, Result.GetBuffer(len), len);
Result.ReleaseBuffer(len);
MessageBox(Result);
}
This works, except for the fact that GetDlgItem always returns NULL! Therefore, I get an access violation each time I run this code.
Any help? Please?