Experts pls !!! problem in Adding items to a subclassed CListCtrl class

Hi,

I am adding item to a subclassed class of CListCtrl. What is teh
correct place to add items in subclassed CListCtrl Class .

I did the folowing steps.Pls let me know where I am goin wrong.

1.In a MFC Doc view with Form view,dragged the CList Control in the
view.

2.Created a class from the class wizard MyListtrlwith base class
CListCtrl.

3.Add a message handler for OnLButtonDown for MyListtrl and added a
Message Box

4.Then in resource view selected teh clistcrl and  add memebr variable
and this time selected MyListtrl and named it m_myListCtrl;

5.When I executed the app,I get message caught in the derived
class.Thats fine.
Now I need to add items in this control,Where should I add???
CMyListCtrl::CMyListCtrl()
{
	//Set the column name
	InsertColumn(1,"H2",LVCFMT_LEFT,100);



	//Add items here

}
I addded in MyListtrl  CONSTRUCTOR BUT got an debug assertion failed
WITH AFXCM.INL line 186.
Where shoudl I add the items so that it can be seen .I also tried in
adding  Create handler of MyListtrl .
When I click right button then my derived class message is getting
called .

Pls guide.
Thanks in advance

0
nicetom786 (68)
5/11/2006 3:17:15 PM
vc.mfc 33608 articles. 0 followers. Follow

7 Replies
556 Views

Similar Articles

[PageSpeed] 4

You want to add your items in the CFormView::OnInitialUpdate, or at least
after the OnInitialUpdate has been called.

AliR.


<nicetom786@yahoo.com> wrote in message
news:1147360635.636361.277400@q12g2000cwa.googlegroups.com...
> Hi,
>
> I am adding item to a subclassed class of CListCtrl. What is teh
> correct place to add items in subclassed CListCtrl Class .
>
> I did the folowing steps.Pls let me know where I am goin wrong.
>
> 1.In a MFC Doc view with Form view,dragged the CList Control in the
> view.
>
> 2.Created a class from the class wizard MyListtrlwith base class
> CListCtrl.
>
> 3.Add a message handler for OnLButtonDown for MyListtrl and added a
> Message Box
>
> 4.Then in resource view selected teh clistcrl and  add memebr variable
> and this time selected MyListtrl and named it m_myListCtrl;
>
> 5.When I executed the app,I get message caught in the derived
> class.Thats fine.
> Now I need to add items in this control,Where should I add???
> CMyListCtrl::CMyListCtrl()
> {
> //Set the column name
> InsertColumn(1,"H2",LVCFMT_LEFT,100);
>
>
>
> //Add items here
>
> }
> I addded in MyListtrl  CONSTRUCTOR BUT got an debug assertion failed
> WITH AFXCM.INL line 186.
> Where shoudl I add the items so that it can be seen .I also tried in
> adding  Create handler of MyListtrl .
> When I click right button then my derived class message is getting
> called .
>
> Pls guide.
> Thanks in advance
>


0
AliR3470 (3236)
5/11/2006 3:36:44 PM
Thanks for  quick response  and it worked.
Now When I am adding columsns it worked .
But When I add items I get a debug assertion? Why ??
Pls guide
here is teh code in oninitial update of CFormView

void CMichaelChaseView::OnInitialUpdate()
{

	CFormView::OnInitialUpdate();
	GetParentFrame()->RecalcLayout();
	CString buffer = "Item1";
//	ResizeParentToFit();
	m_myListCtrl.InsertColumn(0, "Column 1");
	m_myListCtrl.InsertColumn(1, "Column 2");
    m_myListCtrl.InsertColumn(2, "Column 3");

    m_myListCtrl.SetColumnWidth(0, 100);
    m_myListCtrl.SetColumnWidth(1, 100);
    m_myListCtrl.SetColumnWidth(2, 100);

 for(int i=0;i<3;i++)
{
m_myListCtrl.InsertItem(i,(LPCTSTR)buffer);
m_myListCtrl.SetItemText(i,1,(LPCTSTR)buffer);

}

0
nicetom786 (68)
5/11/2006 4:14:43 PM
I am not sure, things look fine here.

When you get the assert, press retry.  Write down the filename and line
number. (Post it here)
Also follow the call stack back to your own code, and make sure that it is
really from InsertItem.


AliR.
<nicetom786@yahoo.com> wrote in message
news:1147364082.989532.243540@i39g2000cwa.googlegroups.com...
> Thanks for  quick response  and it worked.
> Now When I am adding columsns it worked .
> But When I add items I get a debug assertion? Why ??
> Pls guide
> here is teh code in oninitial update of CFormView
>
> void CMichaelChaseView::OnInitialUpdate()
> {
>
> CFormView::OnInitialUpdate();
> GetParentFrame()->RecalcLayout();
> CString buffer = "Item1";
> // ResizeParentToFit();
> m_myListCtrl.InsertColumn(0, "Column 1");
> m_myListCtrl.InsertColumn(1, "Column 2");
>     m_myListCtrl.InsertColumn(2, "Column 3");
>
>     m_myListCtrl.SetColumnWidth(0, 100);
>     m_myListCtrl.SetColumnWidth(1, 100);
>     m_myListCtrl.SetColumnWidth(2, 100);
>
>  for(int i=0;i<3;i++)
> {
> m_myListCtrl.InsertItem(i,(LPCTSTR)buffer);
> m_myListCtrl.SetItemText(i,1,(LPCTSTR)buffer);
>
> }
>


0
AliR3470 (3236)
5/11/2006 5:47:20 PM
hI AliR
I  am working on Windows XP?does the code SetItemText run fine on XP?

0
nicetom786 (68)
5/11/2006 5:56:27 PM
tHE assertion is in 
WINCTRL2.CPP Line 494

0
nicetom786 (68)
5/11/2006 5:57:59 PM
Make sure the ListCtrl does not have the LVS_OWNERDATA flag set. (in
resource edit set it to FALSE)

AliR.

<nicetom786@yahoo.com> wrote in message
news:1147370279.188344.52060@j33g2000cwa.googlegroups.com...
> tHE assertion is in
> WINCTRL2.CPP Line 494
>


0
AliR3470 (3236)
5/11/2006 6:01:50 PM
thanks Alir,
It worked 
Thanks
Tom

0
nicetom786 (68)
5/11/2006 7:10:50 PM
Reply:

Similar Artilces:

Recover Deleted Items Outlook 2003
I can't get the DumpsterAlywaysOn trick to work in Outlook 2003. Is there a different way of implementing this in the newer version? Thanks, Patrick are you certain you did not make the same typo in the registry key that you made in this post? that key has always worked for me... "PatricK" <anonymous@discussions.microsoft.com> wrote in message news:ad3601c4369d$f8c98be0$a301280a@phx.gbl... > I can't get the DumpsterAlywaysOn trick to work in > Outlook 2003. Is there a different way of implementing > this in the newer version? > > Thanks, > Patric...

Winmail.dat problem with SBS 2003..and yes i have read the other wiinmail posts
Ok, so I have read thru all the winmail.dat posts in this group and the outlook group, problem is most of them are geared towards ex 5.5. Well I have sbs 2003 and I have one user in my entire company that can not send a excell spreadsheet to one recp. without outlook 2003 i converting into a winmail.dat. I have tryed everyhting I can think of. I reinstalled outlook. I have sett all the options to send as plain text globally and for that contact that gets the winmail.dat files. I have been working on this for a while, but I do believe I checked the setting on exchange to allow the user to ch...

Problems after kb890830 and kb978542 updates
After windows Vista installed kb890830 and kb978542 I noticed 4 problems so far. 1. MSN Service not available, error code: 800706b5. (This happened with previous updates and I fixed the issue by doing a system restore to a previous date.) 2.When I started internet explorer (ver 8.0.6001.18904) I got a message my default search engine was corrupted by another program. 3.I tried the usual system restore and found there were no restore points available 4. I had some unknown problem trying to log into this site. It kept giving a site not available message. I am running windows vis...

Adding Lines And Boxes, etc. To A Chart ?
Hello, Will blame it on my age. Using Excel 2007 (or, at least trying to) and XP. When I have a chart page opened up, how do I get it to show the bar on the bottom (that the real old versions had) that allows one to click on one of its icons shown to "draw" lines, arrowed lines, boxes, add text with a box, etc on the chart itself ? Thanks, Bob Hi, With the chart selected you can use the Insert tab > Illustrations > Shapes. To add shapes to the chart. Textbox is in the Text group of the Insert tab. Cheers Andy -- Andy Pope, Microsoft MVP - Excel http://www.andypo...

Cell Reference Problem with Network
Let's say I have a spreadsheet with two worksheets = SheetA and SheetB. SheetA might reference a cell in SheetB with a formula like =SheetB!A1 But when I move this to the network the reference changes to include the network drive and file name like: ='Z:\FOLDER\[FILE]SheetB!A1 the file may move from my laptop to the network several times and this becomes completely confusion as the reference looks, not within the same spreadsheet which is what I want it to to, but for another file out on the network. How do I explicitly reference a cell within a difference worksheet but alwa...

New entity
when i attach a contact to an account i have an option - to choose an account from the list, or to create a new one. but i dont have this option when i work with two custom entities (1 to many relationships). only to choose from existing when i want a assign a primary entity to a secondary one. is there a workarround? this way makes me press much more buttons in different forms. i have secondary objects already created due to my business proccess, so i need to go to the primary entity, create an object, then to go back, to open a secondary one and to attach the primary one to it. thanks ...

Converting From ADO.Net XML to ADO problem
Using the method described in Microsofts Knowledge Base article http://support.microsoft.com/default.aspx?scid=kb;en-us;316337 to convert an XML file created by a DataSet into an XML file read by ADO. This seems pretty straight forward and the ADO recordset *opens* without error, however it's quite empty. Any attempt to use it (e.g. MoveFirst or RecordCount) causes an E_FAIL error. The translated XML file has lots of data when viewed with a browser. The code is below... DataSet ds = new DataSet(); try { SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM MyTable", SqlCo...

Printing EXCEL items in WORD
Excel seems to work better for tables than WORD's tables; yet when a table created in EXCEL is copied and pasted into a WORD document I caannot get the gridlines to print. Even thouigh in EXCEL the print gridlines instructions are checked. What should I do? I've always apply borders--either in Excel or in Word. In Word: select a cell in the table Table|Select|Table Format|borders and shading|borders tab check the All icon. The gridlines in Word don't print. Word's help says to use borders. (I just checked.) Old Red One wrote: > > Excel seems to work bett...

Problems with Crystal Reports
Hi everyone We are currently encountering a problem with Crystal Reports on MSCRM. Launching one takes about 10-15 seconds before data is displayed (even if only 1 record is retrieved). The standard Accounts reports are worse, we get a Timed Out error everytime. We are deploying MSCRM on 2 servers - CRM Server has dual procs and 1GB RAM. Any suggestions are very much appreciated. Thanks in advance. Regards. Hon Having Crystal reports in CRM 1.0 timeout is a known bug. (Happens after you try to retrieve more than about 10K records.) There is a private hotfix. It will also be fi...

Problem with line Chart
I have the following data: Date Value 1/07 700 3/07 550 9/07 600 10/07 550 7/08 500 9/08 700 2/09 750 8/09 600 I would like to create a simple line chart connecting the Value points. Note that the points correspond to random dates (not evenly spaced). How can I create a line chart that has time on the x-axis, (say shown in months) with a line connecting the Value points, which are shown at various locations in time. Soun...

Urgent OWA 2K3 Setup Problem
I am fairly new to Exchange 2003 and IIS so this may be a silly question. I have a single 2003 Domain and Exchange organisation that contains 2 backend servers, one is for staff the other students. The default email policy is set for e.g user@emailaddress1 a second policy is set to user@emailaddress2 which is applied to all users on server2. I have configured OWA on Server1 which works fine but can't access any mailboxes on Server2. This is where I get a little confused! The settings on the default http virtual servers on both servers point to the default email policy but the mo...

OWA problem on front-end server
I'm currently running Exchange 2003 over Windows 2000 SP4 with a front-end server handling all the OWA and SSL. I've foung that any email ending with ..EML as opposed to .EML (note the extra dot) gets a 404 page not found. However if I log into OWA on a backend server the same email with the ..EML opens no problem. If anyone has some insight into this problem I'd be greatly appreciated. Take a look at: 320089 XCCC: The URLScan Utility Does Not Allow You to Open Messages in OWA http://support.microsoft.com/?id=320089 Thanks, Richard Roddy Microsoft Exchange Support This...

Clear Format problem
I am trying to write a macro to clear ALL format in a range of cell. However, I run into a problem. I am using the Selection.ClearFormats command and it works in most cases, but fails when multiple format are applied to the cell. For example if a cell only contains "Hello wonderful world" all in bold than ClearFormats will remove the bold formatting. But if the cell contains "Hello wonderful world" where only "wonderful" is in bold, than ClearFormats does not work and the word "wonderful" remains in bold. Does anyone know how to clea...

Shared Calendar problems
We have created a secondary mailbox which includes a calendar for booking a conference room. If I want to book the room, I arrange a meeting with the room (using a modified calendar form) and a secretary accepts the meeting. It appears that something in my modified form is causing a mistake, as when the appointment is viewed (by anyone) the meeting time changes to the current time and if the person viewing it closes the appointment down they get the option to save the changes - thus updating the calendar and clearly causing a few nightmares with the booking! Any suggestions as to where my form...

Problems with Colour Printing
Hi there, I have a spreadsheet with multiple sheets containing colour formatting (including graphs) that is regularly printed out in colour and greyscale. The problem I have is that when I need to print out several sheets simultaneously I uncheck the "Greyscale" option under print options and have the print job come out in colour. To print multiple selected sheets in colour I need to change the print options for each individual sheet (about 10 in all) to colour (non- greyscale). One strange peculiarity of this is that some of the sheets will not need to be "Unchecked"...

Outlook/VBScript: I want to retrieved EntryID from TaskItem class
Hi, I have a question concerning the EntryID from the TaskItem class in Outlook. Here's my question I would like to stored the EntryID in an Access Database at the same time that I am saving the rest of the information (DueDate, Owner, Subject...etc) in my table. I do not know if it is possible. My Problem is that the EntryID does not seems to appears when I am saving the Recordset in my Item_Write event. I do not know if it is created after the Item_Write event. I have tried by putting the EntryID in the Item_Close event but I am not getting the value. I am using VBScript. Is there anyway...

Problem with "New Message to Contact"
I've created an Exchange public folder, which contains 50 contact folders. (This allows us to allow different regions access to just their customers.) I want to send a mail message to a group of customers. So I highlight all the contacts with e-mail addresses, go to the Actions menu and choose "New Message to Contact". I get the following error: "You do not have the permission to send the message on behalf of the specified user." I am the owner of the folder! This method works in a different Exchange public folder, just not in our customer folders. It does...

Data validation causing problems when using a data form in Excel 2
I have an Excel 2007 workbook that includes data validation set on a number of cells. When using a data form to enter data and I enter an invalid value on the form field corresponding to one of those cells I receive the validation error dialogue that prompts me to retry. I enter the correct data into that field on the form then close the form. My worksheet only has the data relating to the corrected field entered. All other data entered via the form is not entered onto the worksheet. Is this a bug in Excel 2007? I previously was using Excel 2002 and found that when using a ...

Learning C# properties from O'Relly book
In a simple time class, int hour /* public int Hour // This works { get { return hour; } set { hour = value; } } */ // Automatic property? public int Hour { get; set; } // This doesn't set hour ! // Client code Time t = new Time(now); int theHour = t.Hour; Console.WriteLine("\nRetrieved the hour: {0}\n", theHour); theHour++; Console.WriteLine("\nUpdated the hour: {0}\n", theHour); Michael Hanson wrote: > [...] > // Automatic property? > public int Hour { get; set; } // This doesn't set hour ! W...

Adding Formula to Existing Cells
In Excel, I have a column with various numbers in each row. I want to multiple each number by 1.02. Short of doing this with extra columns, is there a way to use find/replace and add *1.02 to whatever is already existing in each cell? Paige, Enter 1.02 in some blank cell and copy that cell. Then select the number you want to multiply by 1.02. Go to the Edit menu, choose Paste Special, and choose the Multiply operation. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com chip@cpearson.com "paige" <anonymous@discussio...

Nz & Dlookup problem
I keep getting the #Error in my text box. What is wrong with this syntax? =Nz(DLookUp("[Affiliation]","tblFaculty","[FacID] =" & [Outside]),"") Check the Dlookup 1. Check if the name are correct 2. If FacID field is a text field and not numeric, add a single quote before and after the criteria DLookUp("[Affiliation]","tblFaculty","[FacID] ='" & [Outside] & "'") 3. In any case, try running the dlookup without the text box using the Immidate windows (press Ctrl+g) and then type ?DLookUp(&qu...

SUm function and adding rows
Is there a way to get the SUM function to increase the range if a row is added right above the previous SUM range. FOr example to go from SUM(C3, C22) to SUM (C3, C23) when I insert a row directly above row 24 - wher the SUM function resides. You could use a formula like this in C23: =SUM(C2:OFFSET(C23,-1,0)) FredZack wrote: > > Is there a way to get the SUM function to increase the range if a row is > added right above the previous SUM range. FOr example to go from SUM(C3, C22) > to SUM (C3, C23) when I insert a row directly above row 24 - wher the SUM >...

Fore Color Field Problem
Hi I have problem with fields from the main form that thier value is from a subform query subtotal result - after the main form is open I changed the fore color to red and I saw that with the debugger but when I open the main form I see that the fore color of the fields is black again. I don't know what is the cause for changing of the fields for color from red to black again. Can you please help me with that? Thanks On May 5, 2:31 pm, hmadyson <hmady...@discussions.microsoft.com> wrote: > I think that this is going to be tricky to solve without seeing your > application, ...

Need to take out checkboxes from from some items of the listcontrol.. #2
Hi, I have a listcontrol in which i want to have checkboxes for only selected items.... For that i m trying , m_cListCtrl.SetItemState(nRow , LVS_EX_TRACKSELECT, LVS_EX_TRACKSELECT); which is not working..... PLease help me.. Lotz of thanx in advance, This link may be useful http://www.codeproject.com/useritems/LVChecked.asp Regards Amar ...

Access 2003: Select Next Item in Combobox
Hello, I have a combobox on a form and currently I manually select the next item for a member as needed. This is fine for 1 or 2 but typically I have to do this for 20+. Is there a way to select the next item on the list either using an update query or code? -- Regards, Chris Here's some additional information. On the form that the combobox is on I also have a checkbox labelled Ready. On the update if the checkbox is selected then I want the combobox to select the next item on the list. -- Regards, Chris "eckert1961" wrote: > Hello, > >...