My beautiful function
-
since the item number in a CListCtrl (ICON view) doesn't really reflect its on-screen position, i am forced to execute this function to arrange things work after a drag and drop. note that all i do here is copy the items out, clear the control, then put the items back exactly as they came out. i was mad when i wrote this.
struct stupidFuckingHack
{
std::string txt;
LV_ITEM lvi;
};void CTIFFAssemblerListView::ReorderTheFuckingList()
{
/*
first, get all the fucking items in the fucking CListCtrl
*/
std::vector<stupidFuckingHack> items;
char title[MAX_PATH + 1];
for (int i=0; i *lt; GetListCtrl().GetItemCount(); i++)
{
stupidFuckingHack shit;ZeroMemory(&shit.lvi, sizeof (LV\_ITEM)); shit.lvi.iItem = i; shit.lvi.mask = LVIF\_TEXT | LVIF\_IMAGE | LVIF\_PARAM; shit.lvi.pszText = title; shit.lvi.cchTextMax = MAX\_PATH; GetListCtrl().GetItem( &shitem.lvi); shit.txt = title; items.push\_back(shit);
}
/*
hold on.. don't let the user see this
*/
GetListCtrl().LockWindowUpdate();/*
delete every fucking thing
*/
GetListCtrl().DeleteAllItems();/*
put them all back in, exactly as they came out. duh.
*/for (i=0; i < items.size(); i++)
{
stupidFuckingHack &shit = items.at(i);shit.lvi.pszText = (char \*)shit.txt.c\_str(); shit.lvi.mask = LVIF\_TEXT | LVIF\_IMAGE | LVIF\_PARAM; GetListCtrl().InsertItem(&shit.lvi);
}
/*
now things are as they should be, you piece of shit control
*/
GetListCtrl().UnlockWindowUpdate();
}(If there's a better way, tell me!) -c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses.
/. #3848917You are in my territory now!! I thought I was the only one who wrote vile code. It was always a good thing my products didn't come with source code!! Finally I have something in common with my fellow CPians! :-D
-
since the item number in a CListCtrl (ICON view) doesn't really reflect its on-screen position, i am forced to execute this function to arrange things work after a drag and drop. note that all i do here is copy the items out, clear the control, then put the items back exactly as they came out. i was mad when i wrote this.
struct stupidFuckingHack
{
std::string txt;
LV_ITEM lvi;
};void CTIFFAssemblerListView::ReorderTheFuckingList()
{
/*
first, get all the fucking items in the fucking CListCtrl
*/
std::vector<stupidFuckingHack> items;
char title[MAX_PATH + 1];
for (int i=0; i *lt; GetListCtrl().GetItemCount(); i++)
{
stupidFuckingHack shit;ZeroMemory(&shit.lvi, sizeof (LV\_ITEM)); shit.lvi.iItem = i; shit.lvi.mask = LVIF\_TEXT | LVIF\_IMAGE | LVIF\_PARAM; shit.lvi.pszText = title; shit.lvi.cchTextMax = MAX\_PATH; GetListCtrl().GetItem( &shitem.lvi); shit.txt = title; items.push\_back(shit);
}
/*
hold on.. don't let the user see this
*/
GetListCtrl().LockWindowUpdate();/*
delete every fucking thing
*/
GetListCtrl().DeleteAllItems();/*
put them all back in, exactly as they came out. duh.
*/for (i=0; i < items.size(); i++)
{
stupidFuckingHack &shit = items.at(i);shit.lvi.pszText = (char \*)shit.txt.c\_str(); shit.lvi.mask = LVIF\_TEXT | LVIF\_IMAGE | LVIF\_PARAM; GetListCtrl().InsertItem(&shit.lvi);
}
/*
now things are as they should be, you piece of shit control
*/
GetListCtrl().UnlockWindowUpdate();
}(If there's a better way, tell me!) -c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses.
/. #3848917Chris Losinger wrote: (If there's a better way, tell me!) Well, as far as efficiency goes, since you know in advance how many items you're dealing with, you could pre-allocate them, both for the vector and the list (after you've deleted them)(not sure how the list handles memory allocation after items have been deleted; it might not be any benefit; shouldn't hurt though). Optimizations like this wouldn't matter if you've only got a few items at any given time though. Could make a huge difference once you get several hundred (list is pretty slow WRT re-allocating memory). As far as functionality, maybe use
SetRedraw()
instead ofLockWindowUpdate()
? Everything else looks ok, except for the asterisks in the symbol names... ;)Shog9 --
Maybe Java is kind of like God, it "works in mysterious ways". It seems like your apps are running slowly, because in the backgroud Java is solving world hunger, or finding the cure to cancer. - Ryan Johnston, Don't die java!
-
Chris Losinger wrote: (If there's a better way, tell me!) Well, as far as efficiency goes, since you know in advance how many items you're dealing with, you could pre-allocate them, both for the vector and the list (after you've deleted them)(not sure how the list handles memory allocation after items have been deleted; it might not be any benefit; shouldn't hurt though). Optimizations like this wouldn't matter if you've only got a few items at any given time though. Could make a huge difference once you get several hundred (list is pretty slow WRT re-allocating memory). As far as functionality, maybe use
SetRedraw()
instead ofLockWindowUpdate()
? Everything else looks ok, except for the asterisks in the symbol names... ;)Shog9 --
Maybe Java is kind of like God, it "works in mysterious ways". It seems like your apps are running slowly, because in the backgroud Java is solving world hunger, or finding the cure to cancer. - Ryan Johnston, Don't die java!
yeah. there are only going to be a few items in this list. efficiency isn't a concern here. -c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses.
/. #3848917 -
since the item number in a CListCtrl (ICON view) doesn't really reflect its on-screen position, i am forced to execute this function to arrange things work after a drag and drop. note that all i do here is copy the items out, clear the control, then put the items back exactly as they came out. i was mad when i wrote this.
struct stupidFuckingHack
{
std::string txt;
LV_ITEM lvi;
};void CTIFFAssemblerListView::ReorderTheFuckingList()
{
/*
first, get all the fucking items in the fucking CListCtrl
*/
std::vector<stupidFuckingHack> items;
char title[MAX_PATH + 1];
for (int i=0; i *lt; GetListCtrl().GetItemCount(); i++)
{
stupidFuckingHack shit;ZeroMemory(&shit.lvi, sizeof (LV\_ITEM)); shit.lvi.iItem = i; shit.lvi.mask = LVIF\_TEXT | LVIF\_IMAGE | LVIF\_PARAM; shit.lvi.pszText = title; shit.lvi.cchTextMax = MAX\_PATH; GetListCtrl().GetItem( &shitem.lvi); shit.txt = title; items.push\_back(shit);
}
/*
hold on.. don't let the user see this
*/
GetListCtrl().LockWindowUpdate();/*
delete every fucking thing
*/
GetListCtrl().DeleteAllItems();/*
put them all back in, exactly as they came out. duh.
*/for (i=0; i < items.size(); i++)
{
stupidFuckingHack &shit = items.at(i);shit.lvi.pszText = (char \*)shit.txt.c\_str(); shit.lvi.mask = LVIF\_TEXT | LVIF\_IMAGE | LVIF\_PARAM; GetListCtrl().InsertItem(&shit.lvi);
}
/*
now things are as they should be, you piece of shit control
*/
GetListCtrl().UnlockWindowUpdate();
}(If there's a better way, tell me!) -c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses.
/. #3848917I don't understand
for (int i=0; i *lt; GetListCtrl().GetItemCount(); i++)
But have you considered using a forking parallel sorting index ? Regardz Colin J Davies
Sonork ID 100.9197:Colin
I am sick of fighting with Martin, I think I will ignore his posts from here on in, and spend the time working on articles instead. Christian Graus
-
I don't understand
for (int i=0; i *lt; GetListCtrl().GetItemCount(); i++)
But have you considered using a forking parallel sorting index ? Regardz Colin J Davies
Sonork ID 100.9197:Colin
I am sick of fighting with Martin, I think I will ignore his posts from here on in, and spend the time working on articles instead. Christian Graus
i even considered a recursive function, just to really prove my anger. :) -c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses.
/. #3848917 -
i even considered a recursive function, just to really prove my anger. :) -c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses.
/. #3848917ah, I don't use ListCtrls as they are too fancy for me, but the old ListBox let you Insert and Delete effortleslly. Its a shame they don't allow you to InsertItems() and then RedrawItems() simply. :-( Regardz Colin J Davies
Sonork ID 100.9197:Colin
I am sick of fighting with Martin, I think I will ignore his posts from here on in, and spend the time working on articles instead. Christian Graus
-
since the item number in a CListCtrl (ICON view) doesn't really reflect its on-screen position, i am forced to execute this function to arrange things work after a drag and drop. note that all i do here is copy the items out, clear the control, then put the items back exactly as they came out. i was mad when i wrote this.
struct stupidFuckingHack
{
std::string txt;
LV_ITEM lvi;
};void CTIFFAssemblerListView::ReorderTheFuckingList()
{
/*
first, get all the fucking items in the fucking CListCtrl
*/
std::vector<stupidFuckingHack> items;
char title[MAX_PATH + 1];
for (int i=0; i *lt; GetListCtrl().GetItemCount(); i++)
{
stupidFuckingHack shit;ZeroMemory(&shit.lvi, sizeof (LV\_ITEM)); shit.lvi.iItem = i; shit.lvi.mask = LVIF\_TEXT | LVIF\_IMAGE | LVIF\_PARAM; shit.lvi.pszText = title; shit.lvi.cchTextMax = MAX\_PATH; GetListCtrl().GetItem( &shitem.lvi); shit.txt = title; items.push\_back(shit);
}
/*
hold on.. don't let the user see this
*/
GetListCtrl().LockWindowUpdate();/*
delete every fucking thing
*/
GetListCtrl().DeleteAllItems();/*
put them all back in, exactly as they came out. duh.
*/for (i=0; i < items.size(); i++)
{
stupidFuckingHack &shit = items.at(i);shit.lvi.pszText = (char \*)shit.txt.c\_str(); shit.lvi.mask = LVIF\_TEXT | LVIF\_IMAGE | LVIF\_PARAM; GetListCtrl().InsertItem(&shit.lvi);
}
/*
now things are as they should be, you piece of shit control
*/
GetListCtrl().UnlockWindowUpdate();
}(If there's a better way, tell me!) -c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses.
/. #3848917 -
since the item number in a CListCtrl (ICON view) doesn't really reflect its on-screen position, i am forced to execute this function to arrange things work after a drag and drop. note that all i do here is copy the items out, clear the control, then put the items back exactly as they came out. i was mad when i wrote this.
struct stupidFuckingHack
{
std::string txt;
LV_ITEM lvi;
};void CTIFFAssemblerListView::ReorderTheFuckingList()
{
/*
first, get all the fucking items in the fucking CListCtrl
*/
std::vector<stupidFuckingHack> items;
char title[MAX_PATH + 1];
for (int i=0; i *lt; GetListCtrl().GetItemCount(); i++)
{
stupidFuckingHack shit;ZeroMemory(&shit.lvi, sizeof (LV\_ITEM)); shit.lvi.iItem = i; shit.lvi.mask = LVIF\_TEXT | LVIF\_IMAGE | LVIF\_PARAM; shit.lvi.pszText = title; shit.lvi.cchTextMax = MAX\_PATH; GetListCtrl().GetItem( &shitem.lvi); shit.txt = title; items.push\_back(shit);
}
/*
hold on.. don't let the user see this
*/
GetListCtrl().LockWindowUpdate();/*
delete every fucking thing
*/
GetListCtrl().DeleteAllItems();/*
put them all back in, exactly as they came out. duh.
*/for (i=0; i < items.size(); i++)
{
stupidFuckingHack &shit = items.at(i);shit.lvi.pszText = (char \*)shit.txt.c\_str(); shit.lvi.mask = LVIF\_TEXT | LVIF\_IMAGE | LVIF\_PARAM; GetListCtrl().InsertItem(&shit.lvi);
}
/*
now things are as they should be, you piece of shit control
*/
GetListCtrl().UnlockWindowUpdate();
}(If there's a better way, tell me!) -c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses.
/. #3848917You can use * in a function name ? Christian come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
-
since the item number in a CListCtrl (ICON view) doesn't really reflect its on-screen position, i am forced to execute this function to arrange things work after a drag and drop. note that all i do here is copy the items out, clear the control, then put the items back exactly as they came out. i was mad when i wrote this.
struct stupidFuckingHack
{
std::string txt;
LV_ITEM lvi;
};void CTIFFAssemblerListView::ReorderTheFuckingList()
{
/*
first, get all the fucking items in the fucking CListCtrl
*/
std::vector<stupidFuckingHack> items;
char title[MAX_PATH + 1];
for (int i=0; i *lt; GetListCtrl().GetItemCount(); i++)
{
stupidFuckingHack shit;ZeroMemory(&shit.lvi, sizeof (LV\_ITEM)); shit.lvi.iItem = i; shit.lvi.mask = LVIF\_TEXT | LVIF\_IMAGE | LVIF\_PARAM; shit.lvi.pszText = title; shit.lvi.cchTextMax = MAX\_PATH; GetListCtrl().GetItem( &shitem.lvi); shit.txt = title; items.push\_back(shit);
}
/*
hold on.. don't let the user see this
*/
GetListCtrl().LockWindowUpdate();/*
delete every fucking thing
*/
GetListCtrl().DeleteAllItems();/*
put them all back in, exactly as they came out. duh.
*/for (i=0; i < items.size(); i++)
{
stupidFuckingHack &shit = items.at(i);shit.lvi.pszText = (char \*)shit.txt.c\_str(); shit.lvi.mask = LVIF\_TEXT | LVIF\_IMAGE | LVIF\_PARAM; GetListCtrl().InsertItem(&shit.lvi);
}
/*
now things are as they should be, you piece of shit control
*/
GetListCtrl().UnlockWindowUpdate();
}(If there's a better way, tell me!) -c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses.
/. #3848917Ah, you've reminded me of the general horror of using List Controls and trying to get 265-colour icons in the report view. Simon "This is an equal opportunities airline. The pilot is blind." Sonork ID 100.10024
-
You can use * in a function name ? Christian come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
-
since the item number in a CListCtrl (ICON view) doesn't really reflect its on-screen position, i am forced to execute this function to arrange things work after a drag and drop. note that all i do here is copy the items out, clear the control, then put the items back exactly as they came out. i was mad when i wrote this.
struct stupidFuckingHack
{
std::string txt;
LV_ITEM lvi;
};void CTIFFAssemblerListView::ReorderTheFuckingList()
{
/*
first, get all the fucking items in the fucking CListCtrl
*/
std::vector<stupidFuckingHack> items;
char title[MAX_PATH + 1];
for (int i=0; i *lt; GetListCtrl().GetItemCount(); i++)
{
stupidFuckingHack shit;ZeroMemory(&shit.lvi, sizeof (LV\_ITEM)); shit.lvi.iItem = i; shit.lvi.mask = LVIF\_TEXT | LVIF\_IMAGE | LVIF\_PARAM; shit.lvi.pszText = title; shit.lvi.cchTextMax = MAX\_PATH; GetListCtrl().GetItem( &shitem.lvi); shit.txt = title; items.push\_back(shit);
}
/*
hold on.. don't let the user see this
*/
GetListCtrl().LockWindowUpdate();/*
delete every fucking thing
*/
GetListCtrl().DeleteAllItems();/*
put them all back in, exactly as they came out. duh.
*/for (i=0; i < items.size(); i++)
{
stupidFuckingHack &shit = items.at(i);shit.lvi.pszText = (char \*)shit.txt.c\_str(); shit.lvi.mask = LVIF\_TEXT | LVIF\_IMAGE | LVIF\_PARAM; GetListCtrl().InsertItem(&shit.lvi);
}
/*
now things are as they should be, you piece of shit control
*/
GetListCtrl().UnlockWindowUpdate();
}(If there's a better way, tell me!) -c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses.
/. #3848917 -
since the item number in a CListCtrl (ICON view) doesn't really reflect its on-screen position, i am forced to execute this function to arrange things work after a drag and drop. note that all i do here is copy the items out, clear the control, then put the items back exactly as they came out. i was mad when i wrote this.
struct stupidFuckingHack
{
std::string txt;
LV_ITEM lvi;
};void CTIFFAssemblerListView::ReorderTheFuckingList()
{
/*
first, get all the fucking items in the fucking CListCtrl
*/
std::vector<stupidFuckingHack> items;
char title[MAX_PATH + 1];
for (int i=0; i *lt; GetListCtrl().GetItemCount(); i++)
{
stupidFuckingHack shit;ZeroMemory(&shit.lvi, sizeof (LV\_ITEM)); shit.lvi.iItem = i; shit.lvi.mask = LVIF\_TEXT | LVIF\_IMAGE | LVIF\_PARAM; shit.lvi.pszText = title; shit.lvi.cchTextMax = MAX\_PATH; GetListCtrl().GetItem( &shitem.lvi); shit.txt = title; items.push\_back(shit);
}
/*
hold on.. don't let the user see this
*/
GetListCtrl().LockWindowUpdate();/*
delete every fucking thing
*/
GetListCtrl().DeleteAllItems();/*
put them all back in, exactly as they came out. duh.
*/for (i=0; i < items.size(); i++)
{
stupidFuckingHack &shit = items.at(i);shit.lvi.pszText = (char \*)shit.txt.c\_str(); shit.lvi.mask = LVIF\_TEXT | LVIF\_IMAGE | LVIF\_PARAM; GetListCtrl().InsertItem(&shit.lvi);
}
/*
now things are as they should be, you piece of shit control
*/
GetListCtrl().UnlockWindowUpdate();
}(If there's a better way, tell me!) -c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses.
/. #3848917Chris Losinger wrote: (If there's a better way, tell me!) Well, you ought to be using C++ style comments instead of C comments. :-D I work on an installer and uninstaler for drivers, some of the code surrounding API's (or registry hacks to get around using APIs that won't work) are similar, but a little more toned down. Enough to make others who look at the code laugh, but not bad enough to get me fired. Even if you win the rat race, you're still a rat.