Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. Text editor in vc++

Text editor in vc++

Scheduled Pinned Locked Moved ATL / WTL / STL
c++
8 Posts 2 Posters 21 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lolici
    wrote on last edited by
    #1

    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;
    }

    J 1 Reply Last reply
    0
    • L lolici

      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;
      }

      J Offline
      J Offline
      Jochen Arndt
      wrote on last edited by
      #2

      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();
      }

      L 1 Reply Last reply
      0
      • J Jochen Arndt

        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();
        }

        L Offline
        L Offline
        lolici
        wrote on last edited by
        #3

        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!! :)

        J 1 Reply Last reply
        0
        • L lolici

          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!! :)

          J Offline
          J Offline
          Jochen Arndt
          wrote on last edited by
          #4

          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);

          L 1 Reply Last reply
          0
          • J Jochen Arndt

            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);

            L Offline
            L Offline
            lolici
            wrote on last edited by
            #5

            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"

            L 1 Reply Last reply
            0
            • L lolici

              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"

              L Offline
              L Offline
              lolici
              wrote on last edited by
              #6

              Actually, I fixed the second problem!! But still didn't saved in txt.

              J 1 Reply Last reply
              0
              • L lolici

                Actually, I fixed the second problem!! But still didn't saved in txt.

                J Offline
                J Offline
                Jochen Arndt
                wrote on last edited by
                #7

                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 if file.Open was successful. But if that fails calling file.WriteString should throw an execption.

                L 1 Reply Last reply
                0
                • J Jochen Arndt

                  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 if file.Open was successful. But if that fails calling file.WriteString should throw an execption.

                  L Offline
                  L Offline
                  lolici
                  wrote on last edited by
                  #8

                  I'll check it!Thank you very mush for your help!! :)

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups