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. Exception in CListBox::Addstring

Exception in CListBox::Addstring

Scheduled Pinned Locked Moved C / C++ / MFC
10 Posts 4 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.
  • F Offline
    F Offline
    ForNow
    wrote on last edited by
    #1

    My Addstring works fine its in OinitDialog except when I make it ownerdraw then I get an exception however even out it I mean Addstring DrawItem never gets control

    L J 2 Replies Last reply
    0
    • F ForNow

      My Addstring works fine its in OinitDialog except when I make it ownerdraw then I get an exception however even out it I mean Addstring DrawItem never gets control

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      :confused:

      F 1 Reply Last reply
      0
      • F ForNow

        My Addstring works fine its in OinitDialog except when I make it ownerdraw then I get an exception however even out it I mean Addstring DrawItem never gets control

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

        It would be helpful to know which kind of exception and where it occurs. However, has your owner drawn list box also the LBS_HASSTRINGS style? If not, that is probably the reason:

        LB_ADDSTRING message (Windows)[^]:

        If the list box has an owner-drawn style but not the LBS_HASSTRINGS style, this parameter is stored as item data instead of a string. You can send the LB_GETITEMDATA and LB_SETITEMDATA messages to retrieve or modify the item data.

        F 1 Reply Last reply
        0
        • L Lost User

          :confused:

          F Offline
          F Offline
          ForNow
          wrote on last edited by
          #4

          When I step thru the debugger on ClistBox::AddString it (VS debugger) just says breakpoint hit seems like for OwnerDraw I cann't do addstring in OinitDialog Notsure

          L 1 Reply Last reply
          0
          • J Jochen Arndt

            It would be helpful to know which kind of exception and where it occurs. However, has your owner drawn list box also the LBS_HASSTRINGS style? If not, that is probably the reason:

            LB_ADDSTRING message (Windows)[^]:

            If the list box has an owner-drawn style but not the LBS_HASSTRINGS style, this parameter is stored as item data instead of a string. You can send the LB_GETITEMDATA and LB_SETITEMDATA messages to retrieve or modify the item data.

            F Offline
            F Offline
            ForNow
            wrote on last edited by
            #5

            I have that "LBS_HASSSTRINGS" actually just stepping thru the code on ClistBox::AddString the VS debugger comes up with a DialogBox "BreakPoint hit" a message indicating some sort of exception I am wondering if I cannt do AddString in OnitDialog for a OwneDraw litbox ?

            J 1 Reply Last reply
            0
            • F ForNow

              When I step thru the debugger on ClistBox::AddString it (VS debugger) just says breakpoint hit seems like for OwnerDraw I cann't do addstring in OinitDialog Notsure

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              With that little information it's anyone's guess what is going on. I have used AddString in the OnInitDialog method, in normal and owner drawn list boxes.

              F 1 Reply Last reply
              0
              • L Lost User

                With that little information it's anyone's guess what is going on. I have used AddString in the OnInitDialog method, in normal and owner drawn list boxes.

                F Offline
                F Offline
                ForNow
                wrote on last edited by
                #7

                Ok thanks that’s helpful I’ll do some digging

                1 Reply Last reply
                0
                • F ForNow

                  I have that "LBS_HASSSTRINGS" actually just stepping thru the code on ClistBox::AddString the VS debugger comes up with a DialogBox "BreakPoint hit" a message indicating some sort of exception I am wondering if I cannt do AddString in OnitDialog for a OwneDraw litbox ?

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

                  Calling AddString() itself should not raise an exception (provided that the list box window exists) because that just sends the LB_ADDSTRING message. I guess it is happening later when other list box operations are performed.

                  F 1 Reply Last reply
                  0
                  • J Jochen Arndt

                    Calling AddString() itself should not raise an exception (provided that the list box window exists) because that just sends the LB_ADDSTRING message. I guess it is happening later when other list box operations are performed.

                    F Offline
                    F Offline
                    ForNow
                    wrote on last edited by
                    #9

                    I made a custom DDX to create the list box

                    DDX_TextVAL(pDX, IDC_STORAGE_AREAS, storage_area);

                    HWND tempwin = ::GetDlgItem(pDX->m_pDlgWnd->m_hWnd, nIDC);
                    LPTSTR temptr = (LPTSTR)new char[10];
                    ::GetClassName(tempwin, temptr, 10);
                    if (strcmp((char *)temptr, "Edit") == 0)
                    value.Attach(pDX->PrepareEditCtrl(nIDC));
                    else
                    value.Attach(pDX->PrepareCtrl(nIDC));

                        delete temptr;
                    

                    CListBox storage_area

                    V 1 Reply Last reply
                    0
                    • F ForNow

                      I made a custom DDX to create the list box

                      DDX_TextVAL(pDX, IDC_STORAGE_AREAS, storage_area);

                      HWND tempwin = ::GetDlgItem(pDX->m_pDlgWnd->m_hWnd, nIDC);
                      LPTSTR temptr = (LPTSTR)new char[10];
                      ::GetClassName(tempwin, temptr, 10);
                      if (strcmp((char *)temptr, "Edit") == 0)
                      value.Attach(pDX->PrepareEditCtrl(nIDC));
                      else
                      value.Attach(pDX->PrepareCtrl(nIDC));

                          delete temptr;
                      

                      CListBox storage_area

                      V Offline
                      V Offline
                      Victor Nijegorodov
                      wrote on last edited by
                      #10

                      ForNow wrote:

                      I made a custom DDX to create the list box

                      And what for? IMHO, it is not a good idea...

                      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