CListCtrl problem.

Well I just started playing with VC++ yesterday, so keep it simple if you
can.  thx.

Anyway, I'm having problems with a CListCtrl in report view.  The first
column seems to display fine, but the other columns don't.  Have a look at
my function for adding data:

void CMP3RenamerDlg::PopulateList(CString str) {

 CFileFind finder;
 LVITEM lvi;

 CString item;
 CString strWildcard(str);
 strWildcard += _T("\\*.mp3");
 BOOL bWorking = finder.FindFile(strWildcard);
 int i = 0;
 while (bWorking) {
  bWorking = finder.FindNextFile();
  if (finder.IsDots())
  continue;

  // Populate the list with file names.
  item = finder.GetFileName();
  lvi.mask = LVIF_IMAGE | LVIF_TEXT;
  lvi.iItem = i;
  lvi.iSubItem = 0;
  lvi.pszText = (LPTSTR)(LPCTSTR)(item);
  m_cList.InsertItem(&lvi);
  lvi.iSubItem = 1;
  lvi.pszText = (LPTSTR)(LPCTSTR)(item);
  m_cList.SetItem(&lvi);
  lvi.iSubItem = 2;
  lvi.pszText = (LPTSTR)(LPCTSTR)(item);
  m_cList.SetItem(&lvi);
  i++;
 }
 finder.Close();
}



I would think that the code above would put the file name into column 0, 1,
and 2.  But it doesn't.  Column 0 (the default one) works fine, but on most
of the rows, the other columns aren't populated at all.  The couple that do
get populated are populated with the wrong file names.  Does anybody have
any idea what it is I'm doing wrong here?

Thanks,
Joseph Smith


0
12/6/2003 1:27:26 PM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
729 Views

Similar Articles

[PageSpeed] 53

Joseph,

Try this:

////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////
int nItem = m_ctlItems.InsertItem ("Col-0");
m_ctlItems.SetItemText (nItem, 1, "Col-1");
m_ctlItems.SetItemText (nItem, 2, "Col-2");
m_ctlItems.SetItemText (nItem, 3, "Col-3");
////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////

regards
anton

"Joseph Smith" <monkeythumper@hotmail.com> wrote in message
news:0PkAb.67$Dh7.41774094@news.nnrp.ca...
> Well I just started playing with VC++ yesterday, so keep it simple if you
> can.  thx.
>
> Anyway, I'm having problems with a CListCtrl in report view.  The first
> column seems to display fine, but the other columns don't.  Have a look at
> my function for adding data:
>
> void CMP3RenamerDlg::PopulateList(CString str) {
>
>  CFileFind finder;
>  LVITEM lvi;
>
>  CString item;
>  CString strWildcard(str);
>  strWildcard += _T("\\*.mp3");
>  BOOL bWorking = finder.FindFile(strWildcard);
>  int i = 0;
>  while (bWorking) {
>   bWorking = finder.FindNextFile();
>   if (finder.IsDots())
>   continue;
>
>   // Populate the list with file names.
>   item = finder.GetFileName();
>   lvi.mask = LVIF_IMAGE | LVIF_TEXT;
>   lvi.iItem = i;
>   lvi.iSubItem = 0;
>   lvi.pszText = (LPTSTR)(LPCTSTR)(item);
>   m_cList.InsertItem(&lvi);
>   lvi.iSubItem = 1;
>   lvi.pszText = (LPTSTR)(LPCTSTR)(item);
>   m_cList.SetItem(&lvi);
>   lvi.iSubItem = 2;
>   lvi.pszText = (LPTSTR)(LPCTSTR)(item);
>   m_cList.SetItem(&lvi);
>   i++;
>  }
>  finder.Close();
> }
>
>
>
> I would think that the code above would put the file name into column 0,
1,
> and 2.  But it doesn't.  Column 0 (the default one) works fine, but on
most
> of the rows, the other columns aren't populated at all.  The couple that
do
> get populated are populated with the wrong file names.  Does anybody have
> any idea what it is I'm doing wrong here?
>
> Thanks,
> Joseph Smith
>
>


0
12/6/2003 1:41:20 PM
> Well I just started playing with VC++ yesterday, so keep it simple if you
> can.  thx.
>
> Anyway, I'm having problems with a CListCtrl in report view.  The first
> column seems to display fine, but the other columns don't.  Have a look at
> my function for adding data:
>
> void CMP3RenamerDlg::PopulateList(CString str) {
>
>  CFileFind finder;
>  LVITEM lvi;
>
>  CString item;
>  CString strWildcard(str);
>  strWildcard += _T("\\*.mp3");
>  BOOL bWorking = finder.FindFile(strWildcard);
>  int i = 0;
>  while (bWorking) {
>   bWorking = finder.FindNextFile();
>   if (finder.IsDots())
>   continue;
>
>   // Populate the list with file names.
>   item = finder.GetFileName();
>   lvi.mask = LVIF_IMAGE | LVIF_TEXT;
>   lvi.iItem = i;
>   lvi.iSubItem = 0;
>   lvi.pszText = (LPTSTR)(LPCTSTR)(item);

lvi.cchTextMax = strlen(item)+1;
lvi.pszText = new char[ lvi.cchTextMax ];
strcpy( lvi.pszText, item);
m_cList.InsertItem(&lvi);
//    clean up
delete [] lvi.pszText;

because in your case all the items are the same simply do

lvi.iSubItem = 0
m_cList.InsertItem(&lvi);
lvi.iSubItem = 1

m_cList.SetItem(&lvi);
lvi.iSubItem = 2
m_cList.SetItem(&lvi);
//    clean up
delete [] lvi.pszText;

But in most cases you would need to delete the text, set the length,
(lvi.cchTextMax), and _copy_ the data across.

Also how did you create the columns?

Regards,
Simon.
http://www.myoddweb.com/myoddicon.php
Forums: http://www.myoddweb.com/forum


0
12/6/2003 2:05:14 PM
Thanks for the suggestion.  Your code ultimately accomplishes pretty much
the same as mine though.  The result was also the same.  I created my table
columns in the InitDialog method w/ the following code:

m_cList.InsertColumn(0, "File Name", LVCFMT_LEFT, 150, -1);

m_cList.InsertColumn(1, "Song Title", LVCFMT_LEFT, 150, -1);

m_cList.InsertColumn(2, "Artist", LVCFMT_LEFT, 150, -1);

m_cList.InsertColumn(3, "Album", LVCFMT_LEFT, 150, -1);



Thanks for anything you can suggest.



"MyOdd" <spambucket@myoddweb.com> wrote in message
news:bqsnnk$26as1d$1@ID-162430.news.uni-berlin.de...
>
> > Well I just started playing with VC++ yesterday, so keep it simple if
you
> > can.  thx.
> >
> > Anyway, I'm having problems with a CListCtrl in report view.  The first
> > column seems to display fine, but the other columns don't.  Have a look
at
> > my function for adding data:
> >
> > void CMP3RenamerDlg::PopulateList(CString str) {
> >
> >  CFileFind finder;
> >  LVITEM lvi;
> >
> >  CString item;
> >  CString strWildcard(str);
> >  strWildcard += _T("\\*.mp3");
> >  BOOL bWorking = finder.FindFile(strWildcard);
> >  int i = 0;
> >  while (bWorking) {
> >   bWorking = finder.FindNextFile();
> >   if (finder.IsDots())
> >   continue;
> >
> >   // Populate the list with file names.
> >   item = finder.GetFileName();
> >   lvi.mask = LVIF_IMAGE | LVIF_TEXT;
> >   lvi.iItem = i;
> >   lvi.iSubItem = 0;
> >   lvi.pszText = (LPTSTR)(LPCTSTR)(item);
>
> lvi.cchTextMax = strlen(item)+1;
> lvi.pszText = new char[ lvi.cchTextMax ];
> strcpy( lvi.pszText, item);
> m_cList.InsertItem(&lvi);
> //    clean up
> delete [] lvi.pszText;
>
> because in your case all the items are the same simply do
>
> lvi.iSubItem = 0
> m_cList.InsertItem(&lvi);
> lvi.iSubItem = 1
>
> m_cList.SetItem(&lvi);
> lvi.iSubItem = 2
> m_cList.SetItem(&lvi);
> //    clean up
> delete [] lvi.pszText;
>
> But in most cases you would need to delete the text, set the length,
> (lvi.cchTextMax), and _copy_ the data across.
>
> Also how did you create the columns?
>
> Regards,
> Simon.
> http://www.myoddweb.com/myoddicon.php
> Forums: http://www.myoddweb.com/forum
>
>


0
12/8/2003 3:00:04 PM
Reply:

Similar Artilces:

a problem with std::wstring
Hello, I am having problems handling std::wstring objects. Namely, this two sentences: AfxMessageBox(stringObject_1.c_str()); AfxMessageBox(stringObject_2.c_str()); do give the same visual result, while this comparison stringObject_1 == stringObject_2 results false. Any ideas on why can this be happening? Thanking you in advance, David I am sorry, this might not be the right forum to post this message in. Apologises. David Could there be some characters that are not showing (CR/LF for example) in one of the strings. Also, is the case the same? Tom &...

Text fro word problem
Hi Using Office 2007 I have text in word docs. I try to copy and paste into publisher but it pastes with weird spacing and capitalises some words Tried different formats i.e. RTF but still the same even doing it the other way using edit story in word command. Any ideas what is causing this? Thanks Right-click the text box, click change text, text file, browse to your Word document. -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "kim" <kim@discussions.microsoft.com> wrote in message news:722E3D10-7BA7-4130-8A2F-15...

Did Money 2006 Fix 2 problems?
I'm wondering if Money 2006 fixed the following 2 problems: 1) Money 2005 Small Business version would not properly merge bank information with payment received information. The result was two seperate transactions. The fix according to Microsoft is to download bank information into a cash account and then to transfer into the business account. Quite unacceptable. 2) Money 2005 Small Business version would not properly synchronize business accounts with the Pocket PC version. Again, Microsoft suggests using a cash account to do this. This was not a practical solution. I'd...

Book problems and solution for windows 7 07-16-10
Book problems and solution for windows 7 This book takes you step by step to a new world. The world of Windows 7, even if the new system were not know how to use it. Explain everything to you in pictures. You do not need to for a long time to learn In order not to remain afraid of not being able to follow up on your friends, neighbors or family members Problems and solutions for Windows 7 Is a book for all. To small and great. Anyone who wants to learn Do not miss the opportunity to acquire this book because it relieves you of the trouble and the question Problems and solutions for ...

Fax Routing through Email problem
Here is the event ID of my problem and i am unable to route faxes through email. Only MS Windows updates have been applied since this problem has Occured: Event Type: Error Event Source: Microsoft Fax Event Category: Inbound Event ID: 32083 Date: 6/28/2006 Time: 2:55:51 PM User: N/A Computer: ******* Description: Unable to route fax C:\Documents and Settings\All Users\Application Data\Microsoft\Windows NT\MSFax\Queue\1C69AE3F7D060.tif to the requested e-mail address. The following error occurred: 0x8004020F This error code indicates the cause of the error. Check the SMTP server c...

JSON Problem
Hi, My code is below. I am not able to extract the 'name' and 'query' lists from the JSON via a DataContracted Class (below) I have spent a long time trying to work this one out, and could really do with some help... My Json == {"as_of":1266853488,"trends":{"2010-02-22 15:44:48":[{"name":"#nowplaying","query":"#nowplaying"},{"name":"#musicmonday","query":"#musicmonday"},{"name":"#WeGoTogetherLike","query":"#WeGoTogetherLike&q...

Problem installing SFO with VPN user
I have a sales user that attaches to the SBS2003 server and crm via a cisco VPN client. He can access the web crm app fine, but when i try to install the SFO client, in the section where it asks for the URL of the CRM server, it says it cannot find CRM server components. The VPN client uses the SBS2003 server as its primary dns and I can see through NSlookup that it resolves the URL fine, but it still cannot find the server. I need help to get this installed for them. Any suggestions would be appreciated. -- Rick Koppin Blackstone Technology Group http://www.bstonetech.com has th...

outlk 2002 problem sending
I have created an email account and email is coming in to my account. when testing the acct. it works fine. i can't send any email. this is my email message: The following recipient(s) could not be reached: xxxxx.com on 9/19/2004 10:02 PM 473 xxxxxxx relaying prohibited. You should authenticate first I know these accounts are good. Go into the Properties of the account and see if checking "My outgoing Server requires authentication" this is on the Outgoing Server Tab that is accessible via the "More Settings" button. "tg" <anonym...

mfc app and mfc dll linking problems
I have a MFC dialog app which needs to connect to a MFC dll The DLL has been created, and after getting over the initial linker problems by using __declspec(dllimport) and (dllexport) the project now builds and tries to launch. I now get an unhandled exception that only one winapp at a time can run. As my MFC app was created as a winapp, and the dll was created as a winapp, how do I get around this problem? Which one does not need to be CWinApp, and how do i change it? If you have a regular DLL, you will have a WinApp object as well. It can coexit with your main exe. Thats not the issue. I...

MACRO Problem 02-05-10
repost, need help, thanks..... hello, I had recently received a macro that I was needing some help with. it seems to work on columns where there are formula's only. when i try to modify it to work with FORMATS, it "does" work on columns with formula's, but would not paste FORMATS down on columns, "without" formula's. Is there a way to modify it so that it will? not sure what the problem is.. thanks in advance macro works on columns where cells are filled with a formula only. what using to try to paste Formats down a column (that does not hav...

Problem filtering in Project
Okay, what the heck am I missing on this one. It's been a while since I've worked in Access. I'm using Access 2003 (a project file) and SQL Server 2005. I have a form with a subform in it and link between the parent and child form is working just fine. I open another form when the user clicks a button (Button_Click event) on the main form with the following code: Dim stDocName As String Dim stLinkCriteria As String stDocName = "frmPhoto" ' I've tried it with and without the following two lines of code Form_frmPhotos.Filter = "" F...

Range Naming Problems
Let me try this again. I need some expert help. I'm a battering VBA coder (beginner). How would I make the Sheet Name dynamic for this formula? I need to type the name of the sheet (Mask or any other name) in a cell, say A1, and the VBA code below ( I found it on the code here: http://www.microsoft.com/office/community/en-us/wizard.mspx?dg=microsoft.public.excel.misc&tid=9929481c-550f-4c81-a3ea-637cac37464d&cat=en-us-excel&lang=en&cr=US&sloc=en-us&m=1&query=Dynamic+combo+box&type=question&p=1) would pick it up and make the necessary changes: Private Sub...

Contacts problem after running ADC?
We have a 2000 domain sp4, and a 5.5 sp4 machine on a 2000 server sp 4. We are getting ready to set up 2003 exchange and on a 2003 server and then migrate the mailboxes over. We have installed 2003 and then installed the connector on the 2003 machine, but we have not installed 2003 Exchange. I ran Active Directory Connector and now there are 2 problems? 1. On the global directory in Outlook there are 2 entries for every person, one e-mail address and one (what looks like a) custom recipient, how do I get rid of them? 2. Names are not being resolved when you type them in the to: spa...

Sign in email address problem
How do I change my sign in email address. I have change passport to my correct email address and updated my pass word but Money 2004 does not remember the new address or password. Thanks for your help. Hank I'd go into File|Password Manager, delete the Passport, then re-add it with the new Passport sign-in name. "Shorty" <hankxxxx@hankmack.com> wrote in message news:402531f0_4@127.0.0.1... > How do I change my sign in email address. I have change passport to my > correct email address and updated my pass word but Money 2004 does not > remember the new address...

Excel 2007 page break problem
I am having a problem with page breaks. After making up a new sheet, I go to review it in Print Preview, and it appears that every carriage return has automatically inserted a Page Break. This turns a 1 page 8 line sheet into 8, or 16 pages. Also, the pages in Print Preview are blank. When I view the workbook in PAge Break format, I can see the page breaks and all characters, but can't make any break changes. ...

Problem with mail's delivery in XP
I use OUTLOOK 2000 (SP-3) on Windows XP. When I have a switched on firewall I receive (or send) automatically mails only once (from or to Exchange server). Next sending or receiving goes after changing subfolder in Outlook (it doesn't matter which ones). Pressing the Receive/Send button has no effect. If firewall is switched off all delivery processes go automatically (with correct reaction on the Receive/Send button). Do you have any ideas ? Magik ...

Copy/Paste function in Pub 2007 Intermittant problem
Don't know if anyone has encountered this intermittant problem. When I copy and paste once in my publications, I cannot seem to copy and paste a new item. Sometimes it works fine and sometimes I can only paste the original thing I copied over and over. To get rid of the original copied item, I have to close my publication and re-open it again, then the copy/paste function will work again for a while and then it seems to freeze and the whole process starts over and I have to close and re-open again to get rid of the copied item that froze the system. If anyone else has encountered t...

Problem with Pivot table Connecting to SQL 2005 OLAP
When trying to connect to a SQL 2005 OLAP service from Excel 2003 the following error message is displayed. Unable to open connection. Cannot connect to server 'mysql2005'. OLAP server error: The operation requested failed due to network problems. I am logged in with an account that has administrator privilages on the SQL Server. Does this require some additional components for Excel 2003 to be able to connect to SQL 2005 OLAP? ...

Public Folder problems
Situation is as follows: Server1 in parent domain has a single SMTP Connector for internet bound email and incoming email. Server1 is member of RoutingGroup1 Server2 in the child domain is member of RoutingGroup2. Both Routing Groups are connected by a Routing Group connector. Mail between all users mailboxes flows without a problem We have the following issues: Issue 1: Public Folder replication only works one-way: from Server1 to Server2 Issue 2: Users canot send emails to mail-enabled public folders in the other routing group. If they try this, the emails get stuck in the Local Delivery...

Delegations Control Problems
Hy Guys, My problem is: I need to give administrative control for a AD group in different Exchange Servers. Scene: My company is distributed in two domains, a root domain and a child domain. The child domain has all users accounts and that is divided in OUs that represente mys branch offices. My exchange organization has one administrative group with all exchange servers. I need to delegate administrative rights for IT groups in each site that only these IT groups can administer your respectives Servers. I can't that this IT Groups administer other servers in outher sites jus...

Excel Problem #4
This is a multi-part message in MIME format. ------=_NextPart_000_0176_01C5D288.E54ED060 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I have some sheets In every sheet i have a date betwin C50:C80 and the import betwin D50:D90 Is possible that the solution is in other sheet?=20 Thanks Marcello ------=_NextPart_000_0176_01C5D288.E54ED060 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEA...

Problem with CSocket
Hi all. I wrote an MFC application to make an HTTP file transfer between a client and a server. The application receives as input the list of servers to call (in this case, servers are remote devices with an embedded web server), and one by one it sends the file and closes the connection. The sequence of the operations made is this: 1) Dial-up call to device X 2) Open socket on port 80 3) HTTP POST of the file to the device 4) Wait for the response, and analysis to understand if the transfer has gone well or not 5) Open a new socket (after the response, the old socket is closed) 6) HTTP ...

Installing A97 and A2003 together
I have installed A2003 as well as having A97 from before. I have not yet used 2003 but I keep losing my default workgroup. I keep resetting it to my mdw and it keeps reverting to the system.mdw file - even though I have not used A2003. I know I can overcome the main problem by passing the workgroup file as a command line parameter, but I would like it to continue to work as before when double-clicking on an mdb file. Any way to fix it? -- Les Desser (The Reply-to address IS valid) I've never seen this happen, especially in Access 97, which is the most stable version ever develope...

problems with using camera tool to make dashboards
Hi. I am using the camera tool to create a complex dashboard in Excel 2003, using Windows XP (service pack 3) One example of something that I am using the camera to take a picture of is: A two-slice annotated pie chart in cells A1:D15, with a AutoShape big arrow in E8:G8, pointing to a complex, annotated column chart that expands and explains a facet of the data in the important slice in the pie chart in cells H1:M15 The picture of this set of things (pie chart with text boxes, AutoShape arrow, column chart with text boxes) is then squozen down to be 3 inches by 6 inches, so that it fits i...

MFC-app starting WINDOWS Screensaver window z-order problem
Hi! I wrote an MFC-app using VC++.NET 2003, which starts a screensaver using CreateProcess(). It also terminates the screensaver using TerminateProcess() / CloseHandle(). If the user activates mouse/keyboard before my app terminates the screensaver-process, the screensaver terminates itself and the z-order and focus-handling of open windows somehow gets mixed up. this just happens when I use CreateProcess(), when I use PostMessage(WM_SYSCOMMAND, SC_SCREENSAVE, 0) for the standrad-screen-saver, everything works fine, but I dont want to use this approach. maybe the system uses different CreateP...