Exception in CListBox::Addstring
-
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
-
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
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.
-
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.
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 ?
-
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
-
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.
-
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 ?
Calling
AddString()
itself should not raise an exception (provided that the list box window exists) because that just sends theLB_ADDSTRING
message. I guess it is happening later when other list box operations are performed. -
Calling
AddString()
itself should not raise an exception (provided that the list box window exists) because that just sends theLB_ADDSTRING
message. I guess it is happening later when other list box operations are performed.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
-
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
ForNow wrote:
I made a custom DDX to create the list box
And what for? IMHO, it is not a good idea...