How to get text from listbox?

Hello, how can i get selected text from listbox? I tried with GetDlgItemTex() but it didn't work. Thanks for ideas.
If you are using plain old windows ( not a wraaper library like MFC or QT), then you send
messages to the listbox.
There are a lot of messages you can send to a list box - one of them is LB_GETTEXT. The listbox will return the text associated with the currently selected item.
See here:
http://msdn.microsoft.com/en-us/library/bb761313(VS.85).aspx
char chBuffer[MAX_PATH];

DWORD dwSel = SendDlgItemMessage(hwnd, iListBox, LB_GETCURSEL, 0, 0);

if(dwSel != LB_ERR)
{
SendDlgItemMessage(hwnd, iListBox, LB_GETTEXT, dwSel, (LPARAM)(LPSTR)chBuffer);
}


Thank you. I did as lamblion wrote
Topic archived. No new replies allowed.