|
You'll have to create a compare function to handle how it will sort the items, but after that you can just call SortItems. See the MSDN documentation for details and an example.
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
|
|
|
|
|
aafcls wrote: Are there any functions to accomplish this?
See here.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
okay but what action item will take care of the header clicking functionality, because from there I can call sorting method.
|
|
|
|
|
|
In your CListView /CListCtrl -derived class, provide a handler for the HDN_ITEMCLICK notification. Call the SortItems() method from there. See here for more.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
FarPointer wrote: Please check this out :-
Why (send this to me)? I know very well how to sort a list control.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Well to first add the notification for HDN_ITEMCLICK is tough:-
why because the on notify macro is as follows
ON_NOTIFY( wNotifyCode, id, memberFxn ) and the id of the header control is zero unless explicitly set .
Regards,
FarPointer
Blog:FARPOINTER
|
|
|
|
|
FarPointer wrote: Well to first add the notification for HDN_ITEMCLICK is tough:-
Compared to what, chewing gum? It gets added to the message map just like any other. How's that tough?
FarPointer wrote: why because the on notify macro is as follows
ON_NOTIFY( wNotifyCode, id, memberFxn )
Yeah, so?
FarPointer wrote: ...the id of the header control is zero unless explicitly set .
Of course it's zero, and has been since the control's inception. Why would it need to be anything else?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Well not compared to chewing gum
ya my mistake i was expecting the message map to be like this:-
ON_NOTIFY( HDN_ITEMCLICK, 0, OnHeaderClick)
but it will be like this i guess
ON_NOTIFY( HDN_ITEMCLICK, IDC_LIST, OnHeaderClick)
Regards,
FarPointer
Blog:FARPOINTER
|
|
|
|
|
are there any available comparison functions just for a simple list control for a clicked-on header, to be passed to SortItem?
|
|
|
|
|
Other than the one I already provided? It doesn't get much simpler.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
are you referring to the CompareFunction in the article you sent?
in that case, would I have to make use of "GetItemText" to fill in the "items" in CompareFunction? i'm just not sure how to implement this with a list of unknown quantity of items..
|
|
|
|
|
aafcls wrote: in that case, would I have to make use of "GetItemText"
No. You would cast lParam1 and lParam2 to the appropriate pointer value (the pointer value used with SetItemData() ).
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I am very sorry I do not understand.
I do not make use of SetItemData().
All I have is my list control where I have a few InsertColumn()s and SetItemText() accordingly.
When you tell me to cast these as pointers
int CALLBACK CompareFunction(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
...pointing to what exactly?
|
|
|
|
|
Have you tried the sample code in the link David Crow gave you?
They probably point to either an LVITEM or some MFC wrapper class. This information was obtained by reading the docs for the CListCtrl class; you get there by clicking up from DC's link.
earl
|
|
|
|
|
aafcls wrote: I do not make use of SetItemData().
But you must, if SortItems() is to be used, as it internally calls GetItemData() .
aafcls wrote: All I have is my list control where I have a few InsertColumn()s and SetItemText() accordingly.
You'll also need to use InsertItem() .
aafcls wrote: ...pointing to what exactly?
Whatever pointer value you used with SetItemData() .
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
oh I actually did use InsertItem()
when you say to cast lParam1 and lParam2 to where I must have pointed with SetItemData, do I set them to the same pointer value? what makes param1 and param2 unique?
|
|
|
|
|
aafcls wrote: unknown quantity of items
Do you not understand that sort will be called from inside a sorting algorithm and you don't need to be concerned with the quantity of items?
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
I was wondering how other programs store the code and documentation in order to reuse it someday? I have a file/folder structure that has information stored in it but is getting a little out of control? I was wondering how other programmers store their code and documentation for future use? Does anyone use special code management software?
Chris
|
|
|
|
|
Every where I have worked we used Source Code Control software. CVS, PVCS and VSS.
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
Ok, Maybe I didnt write my question right. I am not talking about source control. I do not need to keep track of changes because I always want the newest version.
Example: I have ProjectA, ProjectB, ProjectC. Function1 and Function2 are used in ProjectA and ProjectB. I want to save those functions somewhere so that later on (ProjectF) if those functions are needed I dont have to go "remember" that the functions are in ProjectA and ProjectB. I would like to go out to a file structure or something where that function is stored and then put it into ProjectD.
You kind of see where I am going with this?
I would like to organize a file/folder structure in a way to maximize an ease of finding code (functions,classes,dlls,libraries,sample projects,add-ins,etc).
My first question is I wonder how other programmers store their code in a file/folder structure (If so what does their C++ folder structure look like), or do they use a special program.
I would also like to keep track of the DOxygen code assocated with the source code.
Chris
|
|
|
|
|
chris175 wrote: You kind of see where I am going with this?
I believe so and it still sounds like Source Code Control.
chris175 wrote: I would like to go out to a file structure or something where that function is stored and then put it into ProjectD.
A) File structure will not hold a "function" it will hold "files" so you are still referring to source code.
B) Source control systems provide sharing of files across projects so they manage that part for you.
chris175 wrote: because I always want the newest version.
Wow, have you never introduced new code and then decided you didn't want to keep it? Happens all the time to me then all I have to do is "undo the checkout" and I am back to where I started with a single mouse click!
Have you never made a change that introduced a "bug"? Source Control Systems provide "differencing" which simplifies finding "what" changed that might help "find the bug".
I see nothing in what you posted that would not be solved using Source Code Control system. Personally I never develop anything without using source control.
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
I have introduced new code and then decided I didn't want to keep it. Maybe more examples may help understand...
GetDefaultPrinter.txt
-----------------
Setup:
-----------------
- Add an include directory, C:\Program Files\Microsoft SDK\include
- Add a link to Winspool.lib
-----------------
DOxygen File:
-----------------
-----------------
.h File:
-----------------
bool GetCurrentDefaultPrinter(std::string& s_printer_name);
-----------------
.cpp File:
-----------------
#include "Winspool.h"
bool GetCurrentDefaultPrinter(std::string& s_printer_name)
{
s_printer_name = "";
CPrintDialog cpd(FALSE);
if(!cpd.GetDefaults())
{
return false;
}
s_printer_name = cpd.GetDeviceName();
return true;
}
stdstring - Is Digits.txt
-----------------
DOxygen File:
-----------------
-----------------
.h File:
-----------------
bool Is_String_Digits(const std::string& s_digits);
-----------------
.cpp File:
-----------------
bool Is_String_Digits(const std::string& s_digits)
{
if (s_digits.length() == 0)
return false;
for (int i = 0; i < s_digits.length(); i++)
{
if (!isdigit(s_digits[i]))
return false;
}
return true;
}
I am not trying to argue with you that putting these files into source control is a bad idea. You could if you want to. I just choose not to. What I want to get at is how all these different files are organized. What type of file structure? Do you use any software (besides version control) to accomplish this?
Chris
|
|
|
|
|
I haven't looked into it myself. Seems to me from your replies that you are looking for something that manages a snippets library or code repository type of thing.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
|
|
|
|