Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

CListBox Problem

Posted on 1998-11-23
12
Medium Priority
?
778 Views
Last Modified: 2013-11-20
Using the CListBox class, I try to write a log records into the list box, whenever an event occurs in my application, I use the insertstring() and updatewindow() method to write the event into the listbox, and simultansly, I write the record also into a DB. The problem is that sometimes, when I look at the list, the same event is written there many times, although the event occured only once(1 record in the DB). When I want to clear the box I use the resetcontent() method, but it seem as it doesn't clear the listbox.
Any idea?
Thanks,
Alon
0
Comment
Question by:oak022097
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
12 Comments
 
LVL 3

Expert Comment

by:plaroche
ID: 1325176
InsertString show redraw the listbox, no need to use UpdateWindow().

Could you paste the code where you use InsertString, and also the one where you use ResetContent?
0
 
LVL 2

Expert Comment

by:jstolan
ID: 1325177
Try adding a Trace statement where you insert the string, see how many times your code gets executed.
0
 
LVL 2

Expert Comment

by:wyy_cq
ID: 1325178
if you can not reset content of listBox.
you are sure to get the correct CWnd point(HWND) of ListBox window.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Expert Comment

by:econde
ID: 1325179
Try with a counter added to the string that you post as a log in the listbox.
If the number increases always ( even in the three same strings ), then you must find a bug in your code.
If the number is the same, then there is a problem with the listbox.
0
 

Author Comment

by:oak022097
ID: 1325180
Well, the problem is that a line after the insertstring() function, I add the string into a DB, and when I look at the DB,
there are no duplicate records, so it couldn't be that I get into the same line few times, w/o notice. Am I right?

Thanks again,
Alon
0
 
LVL 2

Expert Comment

by:prasanth
ID: 1325181
Are you perhaps reading DB entries into the list somewhere else? In a onupdate-type command handler?
0
 

Author Comment

by:oak022097
ID: 1325182
NO!
0
 
LVL 1

Expert Comment

by:The_Brain
ID: 1325183
member
m_List1;

m_List1.insertString("BLAH", 3);

in DB=ins

I suggest if you don't have a specific order, to use AddString().
m_List1.AddString(Blah);
in DB...

that should clear the problem.  m_List1.resetContent(); should work.
search me:) if it doesn't.
0
 
LVL 1

Accepted Solution

by:
The_Brain earned 140 total points
ID: 1325184
member
m_List1;

m_List1.insertString("BLAH", 3);

in DB=ins

I suggest if you don't have a specific order, to use AddString().
m_List1.AddString(Blah);
in DB...

that should clear the problem.  m_List1.resetContent(); should work.
search me:) if it doesn't.

0
 

Author Comment

by:oak022097
ID: 1325185
I can't use the addstring, because I need the list to be sorted by the time the string was added to the list, and when using the addstring, it would not insure me this sort.
0
 
LVL 1

Expert Comment

by:The_Brain
ID: 1325186
What type of sort are you talking about?  
Alpha sort is sure,  just check the properties.

 m_List1.InsertString(Blah,0)  //or is that 1? mmm, I'll have to check that.
It actually depends on what order you want to sort it.  Tell me that and I can give you a much more convincing answer...
0
 
LVL 1

Expert Comment

by:The_Brain
ID: 1325187
Another thing is, I have been working with listboxes for this week quite frequently, and I have not had any problems exept duplicates, AND that was because of coding error.  small logic error, undetectable to the scimming eye.  You have to examine CLOSELY to the code which is performing the data input, and you might see a flaw, mostly in arrays, exceedind arrays, lacking size of arrays, and the BIGGEST problem, different sizes of arrays in protocalls and procedures... that is really worth a good look.  JUST examine the process and write down what you think it does this is a great way of debugging small errors. :)
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

618 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