|
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
|
|
|
|
|
See
<code>
WIN32_FIND_DATA find;
SetCurrentDirectory("c:\\temp");
HANDLE handle=FindFirstFile("*.*",&find);
while(FindNextFile(handle,&find)!=0)
DeleteFile(find.cFileName);
or you can use from
FindClose(handle);
|
|
|
|
|
First of all, I'm a beginner. Second, I make a program that should launch an EXE. Not just EXEs, but different games. Some of them launch, but most of them like Call of Duty, Vice City and others don't.Some games say, they cannon find some settings files, some just critical errors, CoD even shows a message that it has searched files in a wrong folder (should be "D:\games\Call of Duty - United Offensive\uo" but he searches in "D:\games\Call of Duty - United Offensive\uo/uo". I've tried all found functions except for CreateProcess. What can cause the problem?
-- modified at 17:26 Thursday 3rd August, 2006
|
|
|
|
|
Well, AFAIK there are two main elements to watch when launching external programs:
. Current directory
. Parameters
If your games EXE relies on the current directory (which may affect the search path) or any given parameters, then that could be a reason.
Have a look at the properties of the launch shortcut to see what it is passing to the OS to launch the programs.
I Dream of Absolute Zero
|
|
|
|
|
Well, now I know the reason: directory parameter of ShellExecute was NULL. Now all works (except for 1 game shows black screen only on loading). Thanks for reply.
-- modified at 10:38 Friday 4th August, 2006
|
|
|
|
|
hi, i want to use ostream to write to a txt file, though i dont want it to automaticly start a new txt file, if a text file already excists, but behave similar as :
FILE* f=fopen("txt.txt","a");
fwrite(buffer,sizeof(buffer),1,f);
thanks
-- modified at 16:22 Thursday 3rd August, 2006
|
|
|
|