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

  • Home
  • SEARCH
  • 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 6477043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:53:59+00:00 2026-05-25T06:53:59+00:00

I am trying to setup a combo box so a user can select an

  • 0

I am trying to setup a combo box so a user can select an option from the dropdown menu and then retrieve what the user selected using Win32 API C++ programming, not MFC. I read John’s post here and I could not get anything to work. I can set the text for the combo box, but I cannot retrieve what the user selected. Here are a few methods I have tried:

                LPTSTR buf;
                ComboBox_GetText(hwnd, buf, 9);
                MessageBox(NULL, buf, NULL, MB_OK);

And

                char* buf;
                GetDlgItemText(hwnd, IDC_COMBO1, buf, 9);
                MessageBox(NULL, buf, NULL, MB_OK);

IDC_COMBO1 is the ID of the combo box and hwnd is the HWND of the current dialog box.
The code for my dialog box with the combo box is:

LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG4 DIALOG 0, 0, 424, 181
STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU
CAPTION "Dialog"
FONT 8, "Ms Shell Dlg"
{
COMBOBOX IDC_COMBO1, 113, 31, 119, 19, CBS_DROPDOWN | CBS_HASSTRINGS
PUSHBUTTON "Button1", IDC_BUTTON1, 188, 112, 50, 14
}

I am using a resource file to do this. Thanks in advance.

  • 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-05-25T06:54:00+00:00Added an answer on May 25, 2026 at 6:54 am

    For the call to ComboBox_GetText the hwnd parameter must be the handle to the combo box itself, not the dialog. You can get that HWND with GetDlgItem(hwnd, IDC_COMBO1);

    Also, you can’t pass an uninitialized pointer to either function; you must pass a pointer to a buffer which you have created.

                char buf[10];
                GetDlgItemText(hwnd, IDC_COMBO1, buf, 9);
                MessageBox(NULL, buf, NULL, MB_OK); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I am trying to setup an entry posting system, where the user can
I'm trying setup a subset of boost and get it properly compiled using bjam,
I'm trying to setup an Apache/PHP/Postgresql server locally on my machine. I'm using Windows
Trying to setup SSL on jetty 7.2.2 using these instructions: http://docs.codehaus.org/display/JETTY/How+to+configure+SSL stuck on 3b:
Trying to setup SVN to use HTTP, with the user/auth user access files. I
I'm trying to setup a DataGrid that contains a column of combo boxes. The
Im trying to setup a program that will accept an incoming email and then
I am trying to set up a combo box that will display a UserName,
I'm trying really hard to implement jQuery UI's combo box example. I have set
I'm trying to make a combo box that pops up with an image. I

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.