about creating listbox in vs2019

Tom Chen 1 Reputation point
2021-01-18T08:35:39.22+00:00

When I created listbox using the following code, I got an unexpected wrong listbox as the picture shown.

-----------------------------

case WM_CREATE:  
        //  
        hListBox = CreateWindowW(_T("LISTBOX"), NULL, WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP| LBS_STANDARD,  
                     20, 20, 260, 280,  
                     hWnd, (HMENU)10000,  
                     (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE),  
                     NULL);  
	SendMessage(hListBox, LB_ADDSTRING, 0, (LPARAM)_T("China"));  
        SendMessage(hListBox, LB_ADDSTRING, 0, (LPARAM)_T("America"));  
	SendMessage(hListBox, LB_ADDSTRING, 0, (LPARAM)_T("England"));  
        break;  

-------------------------------------------

57594-16109586771.png

Windows development | Windows API - Win32
{count} votes

1 answer

Sort by: Most helpful
  1. David Lowndes 4,726 Reputation points
    2021-01-18T09:08:49.36+00:00

    Your code does the right thing for me.
    Do you have some other code that you've not shown?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.