Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7874223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:44:53+00:00 2026-06-03T02:44:53+00:00

There is combo box with two items and button on the main window. Combobox:

  • 0

There is combo box with two items and button on the main window. Combobox:

HWND hCombo;
hCombo = CreateWindow(L"COMBOBOX", L"combobox",
       WS_CHILD | WS_VISIBLE | CBS_SORT | CBS_DROPDOWNLIST,
       10, 55, 232, 500, hWnd, 0, hInstance, 0);

const wchar_t *langEnglish = L"English";
const wchar_t *langRussian = L"Russian";
SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM)langEnglish);
SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM)langRussian);
SendMessage(hCombo, CB_SETCURSEL, 0, 0);

I am trying to get selected item text in the WndProc by clicking on the button:

case WM_COMMAND:                                            
{
    switch(LOWORD(wParam))
    {  
        case IDC_BUTTON_OK:
            wchar_t buf[10];
            hCombo = GetDlgItem(hWnd, IDC_COMBO);
            GetDlgItemText(hCombo, IDC_COMBO, (LPWSTR)buf, 10);
            MessageBox(hWnd, (LPCWSTR)buf, NULL, MB_OK);
            break;
    }

} break;

I am using breakpoint in the MSVS2010 to see buf variable. It contains chinese symbols!!! Message box shows empty message (With the title “Error“). I want to see english text. What is wrong?

This code

nIndex = SendMessage(hCombo, CB_GETCURSEL, 0, 0);
SendMessage(hCombo, CB_GETLBTEXT, nIndex, (LPARAM)buf);

fills buf with the same chinese symbols

SOLUTION:
hCombo = CreateWindow(L”COMBOBOX”, L”combobox”,
WS_CHILD | WS_VISIBLE | CBS_SORT | CBS_DROPDOWNLIST,
10, 55, 232, 500, hWnd, (HMENU)IDC_COMBO, hInstance, 0);

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T02:44:54+00:00Added an answer on June 3, 2026 at 2:44 am

    In order to get currently selected item from CBS_DROPDOWNLIST styled combo box you need CB_GETCURSEL to get selection index and then CB_GETLBTEXT to get the string.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

is there a more simple way to get combobox (WinForms) selected items text? string
I have two controls created on Form_Load , a button and a combobox. I
Let say I have two combo box: combo box A: A B C When
There are various posts on the web about this issue whereby the ComboBox only
Is there a way to disable changing the value of a ComboBox in WPF
Is there a way to set the .Text property of the Wpf ComboBox control
I have a combobox that is filled with data field JobCode from database. There
Seems there's nothing to do… using the combo prototype/lowpro, no problems at all with
I would like to implement a cascading combo selection where there is a master
Given two simple comboboxes I am able to drop down and select items but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.