Thread: Dialog LB output problems.

  1. #1
    Registered User
    Join Date
    Jul 2003

    Dialog LB output problems.

    I am trying to get output to a list box in my dialog working.

    Here is an example of the function I am using.
    SendMessage(GetDlgItem( hChildHandle, IDC_SESSIONS ),LB_ADDSTRING,0,(LPARAM)szText);

    hChildHandle is equal to my main window handle
    do I need a seperate handle for my dialog, if so how do I get it.

    Little confused about handles.

  2. #2
    Programming is fun, mkay?
    Join Date
    Oct 2001

    Post Maybe this ...

    You may want to make the third parameter of SendMessage() look like this:

    (WPARAM) strlen(szText),


    C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
    DirectX Version: 9.0b
    DX SDK: DirectX 8.1 SDK

  3. #3
    Registered User
    Join Date
    Jul 2003
    That didn't work.
    Here is the code for my output function.
    note I am sending main_window_handl,szstring to the function
    void vShowText(HWND	hChildHandle, char *szText)
    	int Line;
    	// add string to the listbox
    	SendMessage(GetDlgItem( hChildHandle, IDC_SESSIONS ),LB_ADDSTRING,(WPARAM)strlen(szText),(LPARAM)szText);
    	// determine number of items in listbox
    	Line = SendMessage(GetDlgItem( hChildHandle, IDC_SESSIONS ),LB_GETCOUNT,0,0);
    	// flag last item as the selected item, to scroll listbox down
    	SendMessage(GetDlgItem( hChildHandle, IDC_SESSIONS ),LB_SETCURSEL,Line-1,0);
    	// unflag all items to eliminate negative highlite
    	SendMessage(GetDlgItem( hChildHandle, IDC_SESSIONS ),LB_SETCURSEL,-1,0);
    	EnableWindow(GetDlgItem(hChildHandle, IDC_SESSIONS ), FALSE );

  4. #4
    Registered User
    Join Date
    Jul 2003
    it was the handle that was the main problem
    I set up a global variable for hDlg then initialized it in the init section of the dialog call back procedure
    then I changed all the function calls to reflect the new handle

    presto it works (except for my send message button lol but I'll work on that)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. dir output problems
    By willc0de4food in forum C Programming
    Replies: 3
    Last Post: 04-18-2006, 05:47 AM
  2. Getting the position of a dialog without parent on the screen
    By stormbringer in forum Windows Programming
    Replies: 1
    Last Post: 08-27-2003, 02:59 AM
  3. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM
  4. problems with output from code
    By simhap in forum C++ Programming
    Replies: 0
    Last Post: 10-08-2001, 12:43 PM