Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hi,
New to this programming stuff. Personal project going on and I am not sure if I am getting the results I am looking for.
I am using visual studio pro, windows forms.
I want to know is it possible to send messages to the listbox display as a result dialog.
I.E;
C++
hr = m_directoutput.GetDeviceType(hDevice, &typeguid);
if (FAILED(hr))
{
    // flag this error
}


How do I send this error message to the listbox, Better yet, what do you call this action in a manner to which I can get more information in doing this using google?
I have searched all over and still no answer.

Thanks in advance
Posted
Updated 15-Nov-11 12:59pm
v2
Comments
Sergey Alexandrovich Kryukov 15-Nov-11 17:04pm    
Tab your UI library: WPF, Forms, what? The answer depends on it.
--SA
Nish Nishant 15-Nov-11 18:17pm    
SA, he says he is using Winforms.
Sergey Alexandrovich Kryukov 15-Nov-11 20:43pm    
Aha, thanks.
--SA

1 solution

Since you are using Winforms, the easiest approach is to have a form with a single ListBox (docked to fill the form), and send it strings that are added to the ListBox. And no, this is not an unusual approach at all. Logging listboxes have been popular since the Win16 days.

You have tagged your question with C++/CLI, so I would suggest that you use _com_error[^] to convert the hresult to a formatted error message string.
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 15-Nov-11 20:45pm    
Sure, a 5. Another problem is thread safety of it which needs Control.Invoke or Control.BeginInvoke.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900