CListCtrl::InsertItem strange behaviour?

Hi everyone,
I have a dialog with a couple of ListCtrl on it.
I'm filling them up with information when the dialog 
initializes. Therefore i have two loops, one for each 
ListCtrl, on both loops I use the same function to insert 
the items:

myListCtrl1.InsertItem(0, anyString);
---
myListCtrl2.InsertItem(0, anyString);

The weird thing is : the first loop InsertItem is always 
inserting the Item on the first position (InsertItem 
returns a 0 always); displacing the previous inserted 
item. 
BUT, the second loop InsertItem is always inserting the 
item on the last position (InsertItem return 0, 1, 2, ....)

How can this be happening? .. I have checked, and both 
List contains the elments inserted (I have certain 
problems with this behaviour, but I would have to paste 
unnecessary code and stuff); and mostly puzzled by this 
behaviuor. If anyone has an explanation, please let me 
know.

BTW, both ListControls have the exaclty the same 
properties.

Thanks a lot
0
anonymous (74719)
1/4/2004 1:41:08 AM
vc.mfc 33608 articles. 0 followers. Follow

1 Replies
1112 Views

Similar Articles

[PageSpeed] 58

Abelardo,

Does the second control have a Sort property set that you have not noticed
perhaps? I usually strike this with Combo boxes...

- Tim

"Abelardo Vacca" <anonymous@discussions.microsoft.com> wrote in message
news:064701c3d263$d33a1460$a001280a@phx.gbl...
> Hi everyone,
> I have a dialog with a couple of ListCtrl on it.
> I'm filling them up with information when the dialog
> initializes. Therefore i have two loops, one for each
> ListCtrl, on both loops I use the same function to insert
> the items:
>
> myListCtrl1.InsertItem(0, anyString);
> ---
> myListCtrl2.InsertItem(0, anyString);
>
> The weird thing is : the first loop InsertItem is always
> inserting the Item on the first position (InsertItem
> returns a 0 always); displacing the previous inserted
> item.
> BUT, the second loop InsertItem is always inserting the
> item on the last position (InsertItem return 0, 1, 2, ....)
>
> How can this be happening? .. I have checked, and both
> List contains the elments inserted (I have certain
> problems with this behaviour, but I would have to paste
> unnecessary code and stuff); and mostly puzzled by this
> behaviuor. If anyone has an explanation, please let me
> know.
>
> BTW, both ListControls have the exaclty the same
> properties.
>
> Thanks a lot


0
Tim
1/4/2004 9:04:35 AM
Reply:

Similar Artilces:

CListCtrl Header height change??
CListCtrl Header height change?? Is it possible to change the height of a CListCtrl Header.? Thanks Markus ...

Gettign strange server message
This is a multi-part message in MIME format. ------=_NextPart_000_0014_01CB152C.FB9484F0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit It seems that many times when I close my web browser I'm getting an unusual error message dialog. See attached image file. Thanks for your time. -- JamesKB ------=_NextPart_000_0014_01CB152C.FB9484F0 Content-Type: image/jpeg; name="whenclosingbrowsermessage.jpg" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename=&...

Getting a strange error when I try to view an XML file from VS.NET
The error message that I'm getting is: "Cannot find the file 'C:\text.xml' (or one of its components). Make sure the path and filename are correct and that all required libraries are available". I've attached the file that I have saved at C:\text.xml. It's a simple XML file that I threw together for testing. But it's giving me that error. Does anyone have any idea why I might be getting this, and (more importantly) how I can fix it? Thanks! -Scott begin 666 test.xml M/#]X;6P@=F5R<VEO;CTG,2XP)R!E;F-O9&EN9STG=71F+3@G(#\^#0H\<75O M=&4^#0H\5&...

CTreeCtrl and CListCtrl problem
I use create a single document struct using MFC(explore style).The left of the window is CLeftView class(which inherit CTreeView).The right is CBrowserView which inherit CListView.I want to display the content of a directory in the right(CListview) when user click the item of the ctreectrl. In the LeftViw I add method "void CLeftView::OnClickItem (NMHDR* pNMHDR, LRESULT* pResult)" because I want to know which item be clicked by user. ////////////////Leftview////////////////////// CTreeCtrl& mtree=GetTreeCtrl(); HTREEITEM item=mtree.GetSelectedItem(); data=mtree.GetItemDat...

Problems with CListCtrl
I'm having trouble with a CListCtrl object. I'm trying to automatically set the selected items of the list from my code. I try the following statement: m_List.SetItem (pos, 0, LVIF_STATE, NULL, 0, LVIS_SELECTED, LVIS_SELECTED, 0); The SetItem function returns non-zero, which supposedly means it was successful. However, I don't see any selection showing up. I even called RedrawItem on this list item, but it didn't help either. Anyone know about this? -Eric >I'm having trouble with a CListCtrl object. I'm trying to automatically >set the selected ite...

Strange messages
I hope someone can provide insight on these strange messages that pop up in my inbox very regularly. Maybe 3 or 4 per day. And they come with slightly different messages. Should I be concerned?? ==== Here is example 1 The from shows as Microsoft Net Mail Storage System [omailrobot@microsoft.net] Hi. I'm sorry I wasn't able to deliver your message to one or more destinations Undelivered message to jdqign@microsoft.net === Here is example 2 The from shows as MS Internet Mail Storage System [emailengine@netmail.com] Hi. This is the qmail program Undelivered to gvhffbj@netmail.com I...

CListCtrl and sub item editting
Hi, Is it possible to implement CListCtrl sub item editting without creating a custom ctrl? I am using VS2003. TIA Tony >Is it possible to implement CListCtrl sub item editting without creating a >custom ctrl? Tony , There's no built-in support for this, so no, you have to provide some implementation for this. Have a look on sites such as CodeGuru and CodeProject, they'll have examples. Dave Thanks Dave, I've seen examples, I just wasnt sure if I needed my own ctrl. Regards Tony "David Lowndes" <DavidL@example.invalid> wrote in message news:k...

Strange VLookup problem
I have a list of part numbers with descriptions in a data range. On a separate worksheet, the user types in the part number and a vlookup puts in the part description in another column. The problem seems to occur with two part numbers only, 2228-120 and 2228-021. If 2228-120 is typed into the part number cell, the vlookup returns the description for part number 2228-021! How do I correct this? (Everything else works properly AFAIK!) Thanks "Gordon" <GordonBP1@yahoo.invalid> wrote in message news:e3sQjTheEHA.332@TK2MSFTNGP09.phx.gbl... > I have a list of part numbers with...

How to add clistctrl into clistctrl?
How to clistctrl into a clistctrl? For example like adding checkbox , combobox, i want to add clistctrl into a clistctrl ...

Upgraded from Exchange 2003 standard to enterprise now I get strange logs
I just upgraded my exchange 2003 server to enterprise. The install went fine and everythign seems to work however I now have information events in my application log. the message is as follows. Event Type: Information Event Source: Ci Event Category: CI Service Event ID: 4109 Date: 11/2/2006 Time: 7:29:43 AM User: N/A Computer: FRASERV_MAIL Description: Master merge was started on c:\system volume information\catalog.wci because more than 20000 documents have changed since the last master merge. For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp...

CListCtrl::InsertItem strange behaviour?
Hi everyone, I have a dialog with a couple of ListCtrl on it. I'm filling them up with information when the dialog initializes. Therefore i have two loops, one for each ListCtrl, on both loops I use the same function to insert the items: myListCtrl1.InsertItem(0, anyString); --- myListCtrl2.InsertItem(0, anyString); The weird thing is : the first loop InsertItem is always inserting the Item on the first position (InsertItem returns a 0 always); displacing the previous inserted item. BUT, the second loop InsertItem is always inserting the item on the last position (InsertItem retu...

icons on 2nd column of a clistctrl
hi, Is it possible to have icons or bitmaps on all of the columns of a clistctrl, not only the 1st column ? thanks, "behzad" <behzadnn@yahoo.com> wrote in message news:#LE9$vvYDHA.2284@TK2MSFTNGP12.phx.gbl... > hi, > Is it possible to have icons or bitmaps on all of the columns of a > clistctrl, not only the 1st column ? Never tried it personally, but according to the LVM_SETITEM documentation... http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/listview/messages/lvm_setitem.asp "In version 4.70 and later, you can se...

Tooltip in CListCtrl
Hi all I have been trying now for a couple of days to figure out a way to display a tooltip over individual items in a CListCtrl. My control is in Report style, and has two columns where the first contains keys, and the second values. Problem is the keys do not have a lot of room, and I would like a tooltip to give a better description of what the key actually refers to. I found an article on Codeguru describing how this could be done, but I did not work for me - my override of CWnd::OnToolHitTest was never called by the framework as the article stated it would... For all I know this article...

strange characters in OWA
hello, we upgraded from exch2000 to exch2003 sp1 on Server 2003. When some people are sending emails from OWA, there is a '?' (question mark symbol) that is inserted at the beginning of the message body as well as strange characters that are inserted in place of an apostrophe character. Anybody see this and know what might be the cause ? thanks Did you ever get a resolution for this issue? I have had the mysterious ? inserted into every mail sent from OWA since the day I launched Small Business server 2003. I have not seen any other strange characters though. Sounds like...

CListCtrl questions
Hi, I am developping on Pocket pc and smartphone and I have a few questions about CListCtrl in report mode. First how can I know how many items I can display without having a vertical scrollbar? On smartphone we are using keypad to move, so first time when I press down key, the curent selection doesn't move.It's only the second time I press the key that is starts to move. First I thought it was a focus problem but even with the focus, it still the same. I also tried to select the first line first with a setitemstate but same result.any idea ? Last question is once a clistctrl h...

SetItemHeight in CListCtrl
Is there a way for me to set the height of all the items in a CListCtrl? I am trying to overlay one of the columns in an item with a CComboxBox and the minimum height in the comboBox appears to be greater than the height of the item in the CListCtrl. Brian Westcott wrote: > Is there a way for me to set the height of all the items in a CListCtrl? I > am trying to overlay one of the columns in an item with a CComboxBox and the > minimum height in the comboBox appears to be greater than the height of the > item in the CListCtrl. > > You have to create OWNERDRAW CLi...

Displaying JPEG images in CListCtrl
Hi All, I am writing an application in which I want to display a set of JPEG images into a CListCtrl. Is there a way of doing this by using just MFC? Awaiting for your reply Thanks & Regards Sachin Bhave > I am writing an application in which I want to display a set of JPEG > images into a CListCtrl. Is there a way of doing this by using just MFC? Try codeguru/codeproject for something like this. Here is one that should get you started: http://www.codeproject.com/listctrl/thumbnailview.asp --- Ajay ...

CListCtrl
I have used LVS_EX_CHECKBOXES extended style for my CListCtrl. Do Parent Window/Dialog receive any notification message when user set/reset the checkbox. I tried to use NM_CLICK , but checkbox value is changed after this notification is processed. ...

TEXT(LPTSTR) strange error
Hi, I have the following function in a .h file : LPTSTR ARGetString(HINSTANCE hInstance, UINT uID) { int iResult = 0; TCHAR sz[2048]; iResult = LoadString(hInstance, uID, sz, (int) (sizeof(sz)/sizeof(TCHAR))); return ((LPTSTR)sz); } in my mainform, i call it to change the text caption like that : ::SetDlgItemText(m_hWhnd, IDC_FILE, TEXT(::ARGetString(hLibrary,1000))); but VC++ displays me the following error : error C2653: 'L' : is not a class or namespace name f:\my documents\loaddll\loaddlldlg.cpp 165 what is the problem ? i'm just trying to make my application using d...

Timesheet approval strange behaviour-Project Server 2007
Dear all, We are using Project Server 2007 Timesheet Module for a Functional Organization. Organization has various Teams. For every Team there is a Team Leader. Team Leaders report to Functional Managers and all Functional Managers report to a Director. All Team Members, Team Leaders and Managers register their Actual Time using Timesheet module. We are using "Fixed Approval" as follows: Team Member A has the Team Leader A of his/her Team as Timesheet Manager. Team Leader A has the Functional Manager A as Timesheet Manager. Functional Manager A Timesheet Appro...

CListCtrl Item Selection Questions
Hi I want to ask several things about CListCtrl here: 1. How to disable multiple item selection? 2. How to disable the column header click? Since I don't have any sorting facility in my application. Thank you very much. Select the ListCtrl object in resource editor and set the following properties Single Selection True No Sort Header True Cheers Check Abdoul --------------------- "Landon" <Landon@discussions.microsoft.com> wrote in message news:589C8584-BE50-4BA0-AA56-58297A072FC3@microsoft.com... > Hi I want to ask severa...

Unable to use CListCtrl.FindItem after CListCtrl.SortItems
I have a CListCtrl which I want to sort, but after I sort I can no longer use FindItem because it always returns a failure. Any assistance with this is greatly appreciated. Thanks! >I have a CListCtrl which I want to sort, but after I sort I can no longer >use FindItem because it always returns a failure. Any assistance with this >is greatly appreciated. Show a concise code example of what you're doing then someone may be able to point out what's wrong. Dave -- MVP VC++ FAQ: http://www.mvps.org/vcfaq LVFINDINFO findinfo; findinfo.flags=LVFI_STRING; findinfo.ps...

Problem with CListCtrl::HitTest
Hi all... I'm programming a Custom Drawn List Control. The problem is when I add a handler for ON_WM_LBUTTONDOWN. This is the code I have in it: void CMyGrid::OnLButtonDown(UINT nFlags, CPoint point) { LVHITTESTINFO ht; ZeroMemory(&ht, sizeof(LVHITTESTINFO)); ht.pt = point; HitTest(&ht); CListCtrl::OnLButtonDown(nFlags, point); } After the call to HitTest, these values are contained in the structure: pt = {x=177 y=179} flags = 1 iItem = -1 iSubitem = 0 regardless I click on an item or not. To know the item and subitem where the click occures, I can use a loop, I think, ...

CListCtrl ?
I was wondering if there is an equivalent statement for the CListCtrl to select a particular? Something like SetCurSel(item number) in a CListBox? What I want is to highlight the insert item and have the list scroll down so that the current item that was inserted is always visible. As it is now the top of the list is always visible. Z.K. You can use SetItemState() and EnsureVisible() to do what you're trying to do. Something like: m_MyList.InsertItem(nItem,_T("New Text For This Item"); m_MyList.SetItemState(nItem, LVIS_SELECTED, LVIS_SELECTED); m_MyL...

Strange problem with meeting requests
I am having a few problems within Exchange 2003 regarding meeting requests. This problem is becoming more frequent now and I am struggling to find a cause or an answer. When meeting requests are set up, sometimes not all recipients will recieve the request. Also if a meeting is updated not all recipients will recieve the update. More recently I have been informed that some people are accepting requests but they are not appearing in the list of attendee's. I have look through as many of the log files as I could and I have not found any errors. Any help would be greatly appreciated....