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. C / C++ / MFC
  4. list and ip control in mfc

list and ip control in mfc

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++sysadmin
4 Posts 2 Posters 0 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.
  • R Offline
    R Offline
    rahuljin
    wrote on last edited by
    #1

    hello, i want to copy the content of ip control and add it to a list control. so try to do this ----

    void Cserver_side_mfcDlg::OnBnClickedOk2()
    {
    BYTE m_M1, m_M2, m_M3, m_M4;
    DWORD s = 0;
    char ss[20] = {0};
    UpdateData();
    m_ipAdd.GetAddress(m_M1, m_M2, m_M3, m_M4);
    m_ipList.InsertItem(s++, LPCTSTR(m_M1));

    }

    it compiles without any error but when i run it and click ok, it shows the error ---

    Unhandled exception at 0x746bc348 in server_side_mfc.exe: 0xC0000005: Access violation reading location 0x00000017.

    i also tried ----

    void Cserver_side_mfcDlg::OnBnClickedOk2()
    {
    BYTE m_M1, m_M2, m_M3, m_M4;
    DWORD s = 0;
    char ss[20] = {0};
    UpdateData();
    m_ipAdd.GetAddress(m_M1, m_M2, m_M3, m_M4);
    sprintf_s(ss, "%s:%s:%s:%s", m_M1, m_M2, m_M3, m_M4);
    m_ipList.InsertItem(s++, (LPCTSTR)ss);

    }

    error ---

    Unhandled exception at 0x5cd3e9ee (msvcr90d.dll) in server_side_mfc.exe: 0xC0000005: Access violation reading location 0x0000006f.

    i also tried something like this which is working without any problem ----

    void Cserver_side_mfcDlg::OnBnClickedOk2()
    {
    BYTE m_M1, m_M2, m_M3, m_M4;
    DWORD s = 0;
    char ss[20] = {0};
    UpdateData();
    m_ipAdd.GetAddress(m_M1, m_M2, m_M3, m_M4);
    m_ipList.InsertItem(s++, _T("ABC"));

    }

    please help.

    _ 1 Reply Last reply
    0
    • R rahuljin

      hello, i want to copy the content of ip control and add it to a list control. so try to do this ----

      void Cserver_side_mfcDlg::OnBnClickedOk2()
      {
      BYTE m_M1, m_M2, m_M3, m_M4;
      DWORD s = 0;
      char ss[20] = {0};
      UpdateData();
      m_ipAdd.GetAddress(m_M1, m_M2, m_M3, m_M4);
      m_ipList.InsertItem(s++, LPCTSTR(m_M1));

      }

      it compiles without any error but when i run it and click ok, it shows the error ---

      Unhandled exception at 0x746bc348 in server_side_mfc.exe: 0xC0000005: Access violation reading location 0x00000017.

      i also tried ----

      void Cserver_side_mfcDlg::OnBnClickedOk2()
      {
      BYTE m_M1, m_M2, m_M3, m_M4;
      DWORD s = 0;
      char ss[20] = {0};
      UpdateData();
      m_ipAdd.GetAddress(m_M1, m_M2, m_M3, m_M4);
      sprintf_s(ss, "%s:%s:%s:%s", m_M1, m_M2, m_M3, m_M4);
      m_ipList.InsertItem(s++, (LPCTSTR)ss);

      }

      error ---

      Unhandled exception at 0x5cd3e9ee (msvcr90d.dll) in server_side_mfc.exe: 0xC0000005: Access violation reading location 0x0000006f.

      i also tried something like this which is working without any problem ----

      void Cserver_side_mfcDlg::OnBnClickedOk2()
      {
      BYTE m_M1, m_M2, m_M3, m_M4;
      DWORD s = 0;
      char ss[20] = {0};
      UpdateData();
      m_ipAdd.GetAddress(m_M1, m_M2, m_M3, m_M4);
      m_ipList.InsertItem(s++, _T("ABC"));

      }

      please help.

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      rahuljin wrote:

      void Cserver_side_mfcDlg::OnBnClickedOk2() { BYTE m_M1, m_M2, m_M3, m_M4; DWORD s = 0; char ss[20] = {0}; UpdateData(); m_ipAdd.GetAddress(m_M1, m_M2, m_M3, m_M4); sprintf_s(ss, "%s:%s:%s:%s", m_M1, m_M2, m_M3, m_M4); m_ipList.InsertItem(s++, (LPCTSTR)ss); }

      You cannot simply typecast a char to LPCTSTR. So use TCHAR ss[20] instead.

      «_Superman_» I love work. It gives me something to do between weekends.

      R 1 Reply Last reply
      0
      • _ _Superman_

        rahuljin wrote:

        void Cserver_side_mfcDlg::OnBnClickedOk2() { BYTE m_M1, m_M2, m_M3, m_M4; DWORD s = 0; char ss[20] = {0}; UpdateData(); m_ipAdd.GetAddress(m_M1, m_M2, m_M3, m_M4); sprintf_s(ss, "%s:%s:%s:%s", m_M1, m_M2, m_M3, m_M4); m_ipList.InsertItem(s++, (LPCTSTR)ss); }

        You cannot simply typecast a char to LPCTSTR. So use TCHAR ss[20] instead.

        «_Superman_» I love work. It gives me something to do between weekends.

        R Offline
        R Offline
        rahuljin
        wrote on last edited by
        #3

        thanks. but then how will i use ---

        sprintf_s(ss, "%s:%s:%s:%s", m_M1, m_M2, m_M3, m_M4);

        _ 1 Reply Last reply
        0
        • R rahuljin

          thanks. but then how will i use ---

          sprintf_s(ss, "%s:%s:%s:%s", m_M1, m_M2, m_M3, m_M4);

          _ Offline
          _ Offline
          _Superman_
          wrote on last edited by
          #4

          _stprintf_s(ss, _T("%d:%d:%d:%d"), m_M1, m_M2, m_M3, m_M4);

          «_Superman_» I love work. It gives me something to do between weekends.

          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