Solved

Multiple Selection in a ListBox Control

Posted on 1997-08-09
4
600 Views
Last Modified: 2013-11-19
I have a list box control in a dialog box, which is associated with  CPropertyPage class.I have selected "Multiple Selection".I have associated a CString variable for the listbox through class wizard.Now the prblem is, when ever I click the tab of the next property page (i.e On killing this property page), I see a crash.When I go through the debugger I come to know that the "LB_GETTEXTLEN" message is sent(in MFC's Source DLGDATA.CPP) an the return value is -1.Can any one help me to resolve the crash?
0
Comment
Question by:Amaresh080997
  • 2
4 Comments
 
LVL 4

Expert Comment

by:mbhakta
ID: 1303455
What version of VC++ are you using ?
0
 

Author Comment

by:Amaresh080997
ID: 1303456
Thanks for replying mbhakta! I am using MFC 4.2.Can u suggest me something?
0
 
LVL 1

Accepted Solution

by:
cnasarre earned 0 total points
ID: 1303457
I'm almost sure that you can't handle a multi-select listbox
with a CString. The data exchange process is not implemented.
You have to do it yourself either in DoDataExchange() or
in OnKillActive()/OnSetActive() of your property page.

You have to use GetSelCount() and GetSelItem() to get each
selected item and store them in a list or whatever you need

0
 

Author Comment

by:Amaresh080997
ID: 1303458
Thanks for the reply cnasarre! Your answer is certainly acceptable.It is the same thing even I thought of.But I was not sure.
By the way, I still leave the question open for answering so that some one who is doubly sure can give it a shot.
Once again thanks a lot for replying cnasarre!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now