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 7075553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:11:29+00:00 2026-05-28T06:11:29+00:00

I have a variable-height owner draw ListBox control. When I call AddString, a MeasureItem

  • 0

I have a variable-height owner draw ListBox control. When I call AddString, a MeasureItem message is sent asking me to tell Windows the size of the item. The problem is, the code hasn’t had a chance to call SetItemData yet, so the code can’t determine the size yet.

I’ve tried calling SetRedraw(FALSE) hoping that would postpone the measure request, but no luck.

So how can I add an item to a CListBox and get the Item Data passed in at the same time? I’ve tried with and without LBS_HASSTRINGS. Not sure what else to try.

  • 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-28T06:11:29+00:00Added an answer on May 28, 2026 at 6:11 am

    If your list box control does not have the LBS_HASSTRINGS style, the pointer argument to AddString() is not considered as a string but as item data (see the remarks section in the documentation for LB_ADDSTRING).

    Therefore, if your list items consist in both a string and some item data, you can wrap these two pieces of information in a structure or a class and pass a pointer to that wrapper to AddString().

    The upside is that both the string and the item data will be available by the time MeasureItem() is called. The downside is that you will have to implement CompareItem() if your list is sorted, and to free the wrappers both when items are deleted and before the list box control is destroyed.

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

Sidebar

Related Questions

I have a ListBox control in WPF which contains items of variable height (predominantly
I have a ListBox which displays items of variable height. I want to show
I have an HTML textarea that is of fixed width, but variable height. I
I have a variable last_login and want to output a message if the last
I have a UITableView with cells containing variable-height UILabels. I am able to calculate
I have a UITableView that is populated with cells of a variable height. I
I have an asynchronous local SSRS 2005 report that is of variable height and
i have a simple website: fixed width, variable height, centered. I want a background
I have two extjs items which are of variable height to be layed out
Is it possible to have variable-height rows within a WinForms ListView in Details mode?

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.