ListBox
-
Hi again I am embarrassed to ask this question, but hey, if you dont ask, you dont get to know... I have an application written by others that generates an Edit Box by using the following code: HWND hwndEdit; hwndEdit = CreateWindowEx(WS_EX_CLIENTEDGE, _T("EDIT"), "", WS_CHILD|WS_VISIBLE|WS_TABSTOP, 20,25,200,23, hWnd, NULL, hInstance, NULL); I now want to add to the program by including a ListBox. Can I do this by: HWND hwndList; hwndList = CreateWindowEx(WS_EX_CLIENTEDGE, _T("LISTBOX"), "", WS_CHILD|WS_VISIBLE|WS_TABSTOP, 20,25,200,23, hWnd, NULL, hInstance, NULL); (changing the co-ords, of course) This does appear to work, but I cant work out how to add strings to the ListBox - can anyone help, or show me what I am doing wrong Thanks for any help that you can give to a newbie! Mike
-
Hi again I am embarrassed to ask this question, but hey, if you dont ask, you dont get to know... I have an application written by others that generates an Edit Box by using the following code: HWND hwndEdit; hwndEdit = CreateWindowEx(WS_EX_CLIENTEDGE, _T("EDIT"), "", WS_CHILD|WS_VISIBLE|WS_TABSTOP, 20,25,200,23, hWnd, NULL, hInstance, NULL); I now want to add to the program by including a ListBox. Can I do this by: HWND hwndList; hwndList = CreateWindowEx(WS_EX_CLIENTEDGE, _T("LISTBOX"), "", WS_CHILD|WS_VISIBLE|WS_TABSTOP, 20,25,200,23, hWnd, NULL, hInstance, NULL); (changing the co-ords, of course) This does appear to work, but I cant work out how to add strings to the ListBox - can anyone help, or show me what I am doing wrong Thanks for any help that you can give to a newbie! Mike
Send the listbox the LB_ADDSTRING message. char szMyString[64]; strcpy(szMyString, "This is my string."); lResult = SendMessage(hwndList, LB_ADDSTRING, 0, (LPARAM)szMyString ); The string should end up in the list box. See other LB_??? messages for the other actions you can perform on the listbox. People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks
-
Send the listbox the LB_ADDSTRING message. char szMyString[64]; strcpy(szMyString, "This is my string."); lResult = SendMessage(hwndList, LB_ADDSTRING, 0, (LPARAM)szMyString ); The string should end up in the list box. See other LB_??? messages for the other actions you can perform on the listbox. People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks
Your a Star! I have just tried that and it works - simple! Thank you very much Mike