|
I thought adding non-duplicate data would be the best way.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
I wonder if you got downvoted for your answer because you didn't provide the full source code? Your answer is perfectly fine. Lot's of idiots around here.
|
|
|
|
|
Thank you.
Voting people sometimes has no adequate technical skills to do it, anyway that's part of the game.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
for me, the best reason for why he's been downvoted is because patching a design issue with code is always a bad solution...
if the list mustn't have duplicates, then it just not have to accept them at first.
Rajesh R Subramanian seemed to have spotted it right
|
|
|
|
|
Actually Carlo suggested that because the OP himself was insisting on that. Even after I suggested him something that is more logical, he went around and asked again "how to do what I azked. pleaze show the sourze codez".
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
toxcct wrote: patching a design issue with code is always a bad solution...
Generally speaking, maybe it is not a design issue (though, on common sense grounds, his code has such issue). Maybe you can't simply avoid duplicate items in the list (i.e. very fast insertion on data acquisition, list already buildt by code out of your control). I simply gave some hints to deal with the actual problem. Anyway I don't bother about downvoting: as I already said, it's part of the game.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
modified on Thursday, August 21, 2008 5:16 AM
|
|
|
|
|
I'll have to agree with Tox also. His argument makes perfect sense to me.
But still, it is nobody's fault, but the down-voting was unreasonable, because the OP himself was aZking for something and you just offered him a viable solution.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Rajesh R Subramanian wrote: I'll have to agree with Tox also. His argument makes perfect sense to me.
I don't agree (but I won't kill you for this, you're my friend ): while it is good design (and generally very desiderable) having a listbox already filled without duplicates, removing duplicates from a set of data is a quite reasonable elaboration task (and learn how to do it may have some value too).
As for downvoting, I don't bother too much: I was thankful to toxcct for trying to give an explanation to such votes, anyway I won't vote 1.0 a post just beacause may philosiphical point of view on the argument is quite different.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: I won't kill you for this, you're my friend
Thanks pal. I thought I'm a dead man after I posted that message.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
You MFC people should be warned about plain-C people rudeness.
BTW Another THHB's stroke!
BTW2: No Rajesh's fans in the lounge [^]. Balanced.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks pal. I forgot to feed my troll with wheat flakes last evening.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
I am gonna have to agree with Michael on that. You must provide sorece codez Carlo.
*Vote balanced*
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Rajesh R Subramanian wrote: I am gonna have to agree with Michael on that. You must provide sorece codez Carlo.
That's right of course. But there was a misunderstanding since the OP probably hasn't yet heard about www.cpallini.freeproductz.com.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: www.cpallini.freeproductz.com.
I thought you would only provide this helpful link for people who put urgentzz, sendz codez plzz in the subject line...
|
|
|
|
|
Just see below. Actually the OP fell for it.
Link ^
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Michael Schubert wrote: I thought you would only provide this helpful link for people who put urgentzz, sendz codez plzz in the subject line...
Indeed.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
That's a complete surpise to me! I should absolutely fix it.
BTW Did you give a try to either:
(a) Avoiding duplicate insertions, as suggested by Rajesh
or
(b) Eliminate the duplicate items, as suggested by Me
?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
You could use a hashtable to filter out the dups. Like CMapStringToString (if you are using MFC).
|
|
|
|
|
As Rajesh said - the best way is to avoid adding duplicates.
Well, if something is blocking you from that, you could use stl::set[^] to remove duplicate entries. Well, you have to pay penalty for performance.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Here i am sending a code which is adding string.And plz tell me how can i remove to add duplicate string..
BOOL CUSBDlg::FileList()
{
//Get Logical Drives
DWORD dwDrives=GetLogicalDrives();
if(0==dwDrives)
{
// return FALSE;
}
DWORD dwCount=0;
char chDriveLabel='A';
char szRootpath[5]={0,0,0,0,0};
while(dwDrives !=0)
{
if ((dwDrives & 1) != 0)
{
sprintf(szRootpath,"%c:\\",chDriveLabel);
//removable drive
if(DRIVE_REMOVABLE==GetDriveType(szRootpath))
{
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
//Removable dirve lable
// std::cout <<"Files in " << szRootpath << std::endl;
m_ListCountries.AddString(szRootpath);
m_tree.InsertItem(szRootpath);
//* represent search all files and directories
szRootpath[3]='*';
hFind=FindFirstFile(szRootpath,&FindFileData);
if (INVALID_HANDLE_VALUE == hFind)
{
// return FALSE;
}
// List all the files in the directory .
do
{
//ignore the sub directories
if (strcmp(FindFileData.cFileName,_T(".")) && strcmp(FindFileData.cFileName,_T("..")))
{
m_ListCountries.AddString(FindFileData.cFileName);
m_tree.InsertItem(FindFileData.cFileName);
}
}while (FindNextFile(hFind, &FindFileData) != 0);
FindClose(hFind);
}
}
dwDrives = dwDrives >> 1;//next drive
chDriveLabel++;
}
return true;
}
Plz help me
|
|
|
|
|
Could you please re-post the code snippet enclosed in "Code Block" so that it will be more easier to read.
NewVC++ wrote: Here i am sending a code which is adding string.And plz tell me how can i remove to add duplicate string..
Well, in the code, Which item do you want to be unique? Being more specific will fast up the responses.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
I am making a Windows service In MFC.I want to show a UI on it. Is it possible? How?
modified on Wednesday, August 20, 2008 7:15 AM
|
|
|
|
|
sumit.durg wrote: I am making a Windows service.I want to show a UI on it. Is it possible? How?
While creating a service you need to specify the flag
SERVICE_INTERACTIVE_PROCESS or Open services.msc and goto the logon tab and check "Allow service to interact with desktop" checkbox.
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
You really should avoid showing ANY user interface in a Windows Service, they typically run when no one is logged in so there is no-one at the PC to either see the UI or use it.
Also, as a Service usually runs as a different user account to the currently logged on user they will not see the UI anyway, especially in Vista when they use a special desktop.
|
|
|
|