PeterOut wrote:
> I am using MSVC++ on Windows ME and have the following event handler
> for when I click on an item in a list box on a dialog box I have built.
>
> void CStereoControlPtsDlg::OnSelchangeInputImages()
> {
> CWnd *cwListBox=GetDlgItem(IDC_INPUT_IMAGES);
>
> *lpNumberOfDocumentsSelected = (long)cwListBox->SendMessage((UINT)
> LB_GETSELITEMS,
> (WPARAM)(lpNumberOfDocumentsSelected), (LPARAM) (lpSelectedIndices));
>
> }
>
> IDC_INPUT_IMAGES is the ID for the list box.
>
> For some reason I get funny values for cwListBox. That is
> cwListBox=0x00bc3ed0
> cwListBox->m_hWnd=0x00000e6c
>
> When I call cwListBox->SendMessage, the program crashes at the
> following point.
> _AFXWIN_INLINE LRESULT CWnd::SendMessage(UINT message, WPARAM wParam,
> LPARAM lParam)
> { ASSERT(::IsWindow(m_hWnd)); return ::SendMessage(m_hWnd, message,
> wParam, lParam); }
> and returns the message.
It looks like you are passing a pointer in WPARAM. A count is expected.
Your code is a mess and the error was caused by failing to use basic MFC
technique. The entire thing should look like this:
int n = m_ListBox.GetSelItems(count, lpSelectedIndices);
Since this requires no casts the compiler would have detected your error.
--
Scott McPhillips [VC++ MVP]