I need help with sending strings to a ListBox

  • Nobody/Anonymous

    Hi, im sending a string to a list box like this:
    SendMessage(hwndLB01, LB_ADDSTRING, 0, (LPARAM) (LPCTSTR) string01); Its kindda of a log window, in the start of all my important functions, i will send a messages to the ListBox saying "Function X() was called" and at the end of the functions ill send a message "function x() returned 0", or returnet 1, etc...

    I have that already working, no problems at all. But what i want now is to place date/time the string was send to the ListBox, right before the String itself. Lines at the ListBox would now  look like "XX/XX HH:MM:SS - Function X() was called.". 

    It would have to be something like that:

    printDebug() {
    datetime() {
    //Here we get Date and Tiem and set at datetimestr
    SendMessage(hwndLB01, LB_ADDSTRING, 0, (LPARAM) (LPCTSTR) , datetimestr, string01);

    But, as i could see in all my lameness theres no way to send a LB_ADDSTRING message with two strings. And if i send two Messages, one with each string, they go in the ListBox in separated lines.

    Can anyone give me some help on that please?

    Thank you :)

    • Nobody/Anonymous

      This is probably a question for Wayne :) He usually has the patient to solve this issues

    • Nobody/Anonymous

      Ops, done. How lame, i did it using strcat :)

  • Lorenzo Tazzari

    Lorenzo Tazzari - 2012-10-08

    I'm programming with DEV C++.
    I creatred one form with 3 listboxes, but only on the first I can add items (rwos), the others two seems to be active but not managed by the program.

    To create the listboxes I worte, under the WM_CREATE:

    hWndListBox1 = CreateWindowEx(0,"LISTBOX", NULL, WS_VISIBLE | WS_CHILD | WS_VSCROLL | WS_BORDER,
    30, 30, 200, 800, hwnd, (HMENU)IDC_LISTBOX_TEXT1, (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE), NULL);
    if (!hwnd)
    MessageBox(NULL, "ListBox 1 Failed.", "Error", MB_OK | MB_ICONERROR);
    SendDlgItemMessage(hwnd, IDC_LISTBOX_TEXT1, WM_SETFONT, (WPARAM)hFont_list, TRUE);

    hWndListBox2 = CreateWindowEx(0,"LISTBOX", NULL, WS_VISIBLE | WS_CHILD | WS_VSCROLL | WS_BORDER,
    330, 400, 200, 418, hwnd, (HMENU)IDC_LISTBOX_TEXT2, (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE), NULL);
    if (!hwnd)
    MessageBox(NULL, "ListBox 2 Failed.", "Error", MB_OK | MB_ICONERROR);
    SendDlgItemMessage(hwnd, IDC_LISTBOX_TEXT2, WM_SETFONT, (WPARAM)hFont_list, TRUE);

    hWndListBox3 = CreateWindowEx(0,"LISTBOX", NULL, WS_VISIBLE | WS_CHILD | WS_VSCROLL | WS_BORDER,
    600, 400, 200, 418, hwnd, (HMENU)IDC_LISTBOX_TEXT3, (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE), NULL);
    if (!hwnd)
    MessageBox(NULL, "ListBox 3 Failed.", "Error", MB_OK | MB_ICONERROR);
    SendDlgItemMessage(hwnd, IDC_LISTBOX_TEXT3, WM_SETFONT, (WPARAM)hFont_list, TRUE);

    The first listbox runs with the call:
    SendMessage(GetDlgItem(hwnd, IDC_LISTBOX_TEXT1), LB_ADDSTRING, 0, (LPARAM)Testo_Val1);

    To add items on the listbox 2 I use:
    SendMessage(GetDlgItem(hWndListBox2, IDC_LISTBOX_TEXT2), LB_ADDSTRING, 0, (LPARAM)Testo_Val2);

    but on the listbox 3 I tried with:
    SendMessage(hWndListBox2, LB_ADDSTRING, 0, (LPARAM)Testo_Val2);

    I also tied with:
    SendMessage(GetDlgItem(hwnd, IDC_LISTBOX_TEXT3), LB_ADDSTRING, 0, (LPARAM)Testo_Val2);

    but without any result.

    I can't understand why the listboxes 2 and 3 aren't managed.


    char Testo_Val1[25];
    char Testo_Val2[25];
    char Testo_Val3[25];

    Thanks in advance for any help!!!

  • Anonymous - 2013-07-17
    Post awaiting moderation.

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks