Text editor in vc++
-
Hi everyone! I need to "send" data in a notepad every time I write double numbers on edit control and press save. I wrote some code but my dialog (where the edit control is) don't even open when I run the executable. What I've done so far:
void CDataDialog::OnBnClickedSave()
{
// TODO: Add your control notification handler code here
CFileDialog dlg(FALSE, L"Text Files (*.txt)|*.txt|Texr Files (*.h)|*.h|", NULL, OFN_OVERWRITEPROMPT, L"Text Files (*.txt)|*.txt|Text Files (*.h)|*.h|");CStdioFile file; CString buffer; CString textfile; if (dlg.DoModal() == IDOK) { file.Open(dlg.GetFileName(), CStdioFile::modeCreate | CStdioFile::modeWrite); dlg.GetFileName(); file.WriteString(buffer); file.Close(); }
}
void CDataDialog::OnEnChangeEdit1()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.// TODO: Add your control notification handler code here UpdateData(TRUE);
}
I think I must write some code here so the dialog box work fine but I can't it.
void CInputView::OnLinefeaturesData()
{
// TODO: Add your command handler code here
CInputDoc* pDoc = GetDocument();
CDataDialog DialogWindow;
} -
Hi everyone! I need to "send" data in a notepad every time I write double numbers on edit control and press save. I wrote some code but my dialog (where the edit control is) don't even open when I run the executable. What I've done so far:
void CDataDialog::OnBnClickedSave()
{
// TODO: Add your control notification handler code here
CFileDialog dlg(FALSE, L"Text Files (*.txt)|*.txt|Texr Files (*.h)|*.h|", NULL, OFN_OVERWRITEPROMPT, L"Text Files (*.txt)|*.txt|Text Files (*.h)|*.h|");CStdioFile file; CString buffer; CString textfile; if (dlg.DoModal() == IDOK) { file.Open(dlg.GetFileName(), CStdioFile::modeCreate | CStdioFile::modeWrite); dlg.GetFileName(); file.WriteString(buffer); file.Close(); }
}
void CDataDialog::OnEnChangeEdit1()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.// TODO: Add your control notification handler code here UpdateData(TRUE);
}
I think I must write some code here so the dialog box work fine but I can't it.
void CInputView::OnLinefeaturesData()
{
// TODO: Add your command handler code here
CInputDoc* pDoc = GetDocument();
CDataDialog DialogWindow;
}You have to show the dialog after it has been created:
void CInputView::OnLinefeaturesData()
{
// TODO: Add your command handler code here
CInputDoc* pDoc = GetDocument();
CDataDialog DialogWindow;
// Now show the dialog
DialogWindow.DoModal();
} -
You have to show the dialog after it has been created:
void CInputView::OnLinefeaturesData()
{
// TODO: Add your command handler code here
CInputDoc* pDoc = GetDocument();
CDataDialog DialogWindow;
// Now show the dialog
DialogWindow.DoModal();
} -
Great!!!I did it!! but how can I save what I write on edit box in a .txt. It worked fine but I din't manage to save what I wrote! Thanks again for your response!! :)
Just get the text from the edit box using
GetWindowText
:CString buffer;
// If you have a class member variable for the CEdit in your CDataDialog class:
m_editBox.GetWindowText(Buffer);
// If not, you have to use the ID:
CEdit *pEdit = (CEdit*)GetDlgItem(IDC_OF_THE_EDIT_BOX);
pEdit->GetWindowText(buffer); -
Just get the text from the edit box using
GetWindowText
:CString buffer;
// If you have a class member variable for the CEdit in your CDataDialog class:
m_editBox.GetWindowText(Buffer);
// If not, you have to use the ID:
CEdit *pEdit = (CEdit*)GetDlgItem(IDC_OF_THE_EDIT_BOX);
pEdit->GetWindowText(buffer);I did it but I didn't manage to save them again. Also when I pressed this message appeared: "Exception thrown at 0x104420C5 (mfc140ud.dll) in Input.exe: 0xC0000005: Access violation reading location 0x00000020. If there is a handler for this exception, the program may be safely continued.------>Break, Continue, Ignore"
-
I did it but I didn't manage to save them again. Also when I pressed this message appeared: "Exception thrown at 0x104420C5 (mfc140ud.dll) in Input.exe: 0xC0000005: Access violation reading location 0x00000020. If there is a handler for this exception, the program may be safely continued.------>Break, Continue, Ignore"
-
Then use the debugger to see what happens (e.g. by setting a break point somewhere after the output file has been selected using the
CFileDialog
). You might also check iffile.Open
was successful. But if that fails callingfile.WriteString
should throw an execption. -
Then use the debugger to see what happens (e.g. by setting a break point somewhere after the output file has been selected using the
CFileDialog
). You might also check iffile.Open
was successful. But if that fails callingfile.WriteString
should throw an execption.