|
I can not do your homework but I can post a few links that should help:
[STL List]
[STL Vector]
JohnLast modified: Thu Aug 3 21:47:49 2006 --
|
|
|
|
|
|
Message deletion with out any reason is crime here
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
His message said 'I hate my class, my teacher can't speak English, but I've been told to write an app that uses 'iterators' to put stuff into a vector and take it out. It's too hard, please write it for me.' My responses are probably why he deleted it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Christian Graus wrote: His message said 'I hate my class, my teacher can't speak English, but I've been told to write an app that uses 'iterators' to put stuff into a vector and take it out. It's too hard, please write it for me.' My responses are probably why he deleted it.
ohh I believe might be your comment generate some respect for teacher in student!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hey all,
thanks to all for ur response.
iam trying to create a listcontrol with 2 columns
I do the following inside OnInitDialog()
m_List1.InsertColumn(0,"column1");
m_List1.InsertColumn(1,"column2");
but how do i insert values. ie., Column1 should have the names like
alex
bob
Cathy
...
...
Column2 their age.
5
12
13
..
..
how do i add these items to the respective columns.
I know I should use InsertItem.
But where in code do I put it ..inside which function.?
Also how to indicate which column it has to be inserted?
Thanks in advance.
|
|
|
|
|
m_List1.InsertColumn(0,"column1");<br />
m_List1.InsertColumn(1,"column2");<br />
<br />
m_List1.AddItem(0, 0, "data for column 1");<br />
m_List2.AddItem(0, 1, "data for column 2");
The first parameter is the row index, and the second parameter is the column or subitem index.
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
Hey I tried including in my code Additem,,,
but I get error saying
AddItem' : is not a member of 'CListCtrl'
..microsoft visual studio\vc98\mfc\include\afxcmn.h(177) : see declaration of 'CListCtrl'
Also, where in my code should I put this Additem function?
|
|
|
|
|
Oops, sorry, I was thinking in ATL/WTL.
For MFC CListCtrl use:
m_List1.InsertItem(0, "data for row 1, column 1");<br />
m_List1.SetItemText(0, 1, "data for row 1, column 2");<br />
<br />
m_List1.InsertItem(1, "data for row 2, column 1");<br />
m_List1.SetItemText(1, 1, "data for row 2, column 2");
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
where exactly in my program (inside what function) do I add these lines to get the values displayed on running the program?
|
|
|
|
|
Depends on at what point you have the data to load into the list control, but I would probably populate the list in OnInitDialog, after you've setup the list control.
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
thanks very much for ur help.
It did help.
Also, is there a function to clear the contents of the listcontrol just like m_list1.ResetContent() for listbox.
|
|
|
|
|
|
Did you see examples from CListCtrl in msdn
and for second question see
<br />
from the msdn<br />
DeleteAllItems Deletes all items from the control. <br />
DeleteColumn Deletes a column from the list view control. <br />
DeleteItem Deletes an item from the control.<br />
|
|
|
|
|
To declare variable public/global what is the best way ,should it be declare through class wizard or in header file of project.
|
|
|
|
|
It's irrelevant. The class wizard just holds your hand and puts the code in your header file. To make it global, you should probably put it in stdafx. However, think carefully about it first, do you really want a global, or do you need to improve your design ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Thanks for your reply,
Let me explain me what i really want
My all the function are declare and define in odl.cpp,odl.h
I am working with dialog based application,so by clicking a button /menu
I have to call that function and store that value in public/global variable so that i can make use of it while calling other function .
my prob is should it b declare as a public through calss wizard or global in .h
|
|
|
|
|
Either way, stop using the class wizard.
I would suggest it needs to be a variable in your class. Does the dialog class have an instance of the other class to set this value on ? If not, is there only ever one instance ? Perhaps it needs to be static, is what I am thinking.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
What do you need? Can you be more specific
|
|
|
|
|
Greetings:
This is probably the most sophomoric question I have ever posted but this situation constantly comes up for me and I would like to know what the accepted method is for resolving it:
I have created two structures. They can contain all manner of member data but each one contains a pointer of the OTHER structure type. I'm sure that made very little sense, so here's a simple example:
<br />
typedef struct<br />
{<br />
AnotherClass* pAN;<br />
} OneClass;<br />
<br />
typedef struct<br />
{<br />
OneClass* pOC;<br />
} AnotherClass;<br />
I'm using Visual Studio 2003. The compiler won't build this because the definition of "OneClass" includes a pointer to "AnotheClass". But "AnotherClass" is not defined yet. I assume that this is because the compiler compiles from the top down and doesn't know about "AnotherClass" when its trying to process "OneClass".
I'm pretty sure that there are classes out there that are part of large, professional level frameworks and libraries that contain these kinds of cyclical references and somehow the compiler doesn't seem to mind.
Correct me if I'm wrong...
Thank you,
Mark
|
|
|
|
|
As the reference is to a pointer, you can just forward declare the other struct instead of an include. That is, something like
struct OneClass;
at the top of the AnotherClass definition file. Or if they are in the same file, just the one that's declared second can be forward declared at the top.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
This can be solved by a forward declaration. following code will compile.
typedef struct
{
struct AnotherClass;
AnotherClass* pAN;
} OneClass;
typedef struct
{
OneClass* pOC;
} AnotherClass;
|
|
|
|
|
Hello,
Can anyone tell me which function I can use to delete all file in a folder. Any standard ANSI C++ function I can used? Thanks!
Nacho
|
|
|
|
|
There are two solutions; one is to get all the files in the directory using findfirst/findnext and then delete them.
The other solution is to use the SHFileOperation.
Oh, I suppose you could spawn cmd and delete that way, but it's lame.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Nacho Chip wrote: Any standard ANSI C++ function I can used?
No. This type of operation will be OS dependent, and will be very different on each system. For Windows, you can use the FindFile API or the Shell interfaces to accomplish this.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|