|
|
Hi everyone,
I have a class like this:
class CFoo
{
public:
CFoo();
~CFoo();
BOOL SortByName();
protected:
std::vector<CRec*> m_Recs;
private:
struct NameComparer
{
bool operator()(const CRec* A,const CRec* B)
{
return ((A->m_strName) < (B->m_strName));
}
};
};
BOOL CFoo::SortByName()
{
std::stable_sort(m_Recs.begin(), m_Recs.end(), NameComparer());
return TRUE;
}
Now, basically, I am trying to properly write and use a predicate function (I think that's what they're called; please correct me if I'm wrong) in the context of calling std::stable_sort (and just std::sort for that matter). There are many helpful examples around, but they don't seem to cover dealing with a non-trivial class (or if they do I haven't 'gotten it' yet).
In my case, I want to be able to sort the vector of CRec 's according to several different CRec member variables (different CString s, int s, double s, etc.). My questions are:
1) Did I use proper coding techniques to solve the problem as I have shown here?
2) Is it the case that I need to add additional struct s under the private section of CFoo for each comparison CFoo member function I want to write (with the comparisons applied to the std::vector m_Recs and based on the CRec members themselves actually)?
3) Why do I need to wrap the comparison functions in a struct? How does that fact relate to operator() , etc.?
Thank you all again for reading and giving any advice,
Best,
Eric
|
|
|
|
|
Any ideas?
|
|
|
|
|
In an MFC application I have to make a Listview in report mode with checkboxes.
One of the entries will be a line called "All" and I have to make sure that this "All" line is the first line and always visible even when scrolling..
Does anyone have an idea how I manage that the easiest
Thanks in advance
Thomas
|
|
|
|
|
It's easy to make the "All" line the first item in the list, but I do not know of a way to ensure that constraint in the presence of scrolling.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Hi..
i am useing 2 CFileFind object but an error keep arise that
the files i used in the first one is still in used i use the Close() fun for the first on. so
How i can delete first CFileFind Object i tried to use only one object but it also give error..
thanks
|
|
|
|
|
Please provide a code snippet exhibiting the problem.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
thanks for your help but i solve the problem
|
|
|
|
|
Why not share with the rest of us? It can be a learning experience for everyone involved.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
I am sorry but it was really silly mistake and if I add I will get too many comments on that …
The mistake was that I was using the same public CFileFind object in two function in each one I use this object and close it once time in the main after I call both so I add the close function in each fun
I really do not mean what you said
|
|
|
|
|
rasha2003 wrote:
I am sorry but it was really silly mistake and if I add I will get too many comments on that …
If the comment you receive is from a professional, it would probably have something constructive in it. Otherwise, if the comment was laced with this-is-crap, what-were-you-thinking, and isn't-it-obvious remarks, you can ignore those anyhow as they serve no other purpose than to humiliate.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Hi..
thank you for that next time i will remember that
|
|
|
|
|
I have a control which when i used in c#. i get the method ShowPropertyPages() through which it displays its properties but when i try the same in VC.NET i will get the error that there is no method ShowPropertyPages defined in the class. what am i doing wrong or what i have to do so that this error will overcome
Thanx in advance
Regards
INAM
Inam
|
|
|
|
|
In my application I am creating an exe file. In that I have embeded an icon. The correct icon is being displayed in windows explorer. But when "on right-click on the exe"/"General tab" displays some other icon. This strange behaviour has been observed in Winodows 98, 95 operating systems.
I have verified the embeded icon inside the exe using "icon grabber" & "resource hacker" applications. It has embeded the correct icon. It does not have the worng icon. (which is getting displayed when "on right-click on the exe"/"General tab")
-Koti
|
|
|
|
|
Does the icon contains both 16x16 and 32x32 bitmaps ?
|
|
|
|
|
Yes. Icon contains both bitmaps.
Thanks,
-Koti
|
|
|
|
|
Hi
I want to write an application , which whenever connects with a FTP Server could tell me wether contents on FTP server has changed since last visit , if changed highlight the changes.
Is there some option in FTP RFC.Thanks
No Worries!
|
|
|
|
|
AFAIR, the FTP-RFC does not define any command or standard by which you could determine if the contents of a server have changed.
But this function would be quite easy to implement:
You request the directory you want to watch. The contents are then saved in a file for future reference. The next time you request that directory, you simply compare the two to check for changes.
Greetings from Germany
Sebastian
|
|
|
|
|
Can someone help me with the code on how can I import the registry information a a specified location to an access database? I am doing a project in Visual C++ to import all installed software information from registry to a database and would appriciate very much for inputs.
|
|
|
|
|
First, you need code that reads information from the registry. Second, you need code that adds information to a data source. Once you have these two in place (they can work independently at first), you can make the appropriate changes such that the output from the former is the input to the latter.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
how do i programatically determine wheather the user has chosen webview or not programatically.
I have tried ShGetSettings but no luck.
Thanx in advance.
Toughest Steel Comes From Hottest Furnance
|
|
|
|
|
Hi,
I'm using CHtmlEditView/CHtmlEditDoc in VC 6.0. It's working well but in testing I found one bug and I could not trace it out yet. i.e. In some times while the user working with editor, suddenly the view becomes blank and the source file size becomes zero. Still I could not find which action makes it blank, I could not trace it out.
Kindly help, what could be the problem to make the entire file blank and is there any chance to happen this in edit/view mode of CHtmlEditView/Doc?
Is anybody hit with this problem?
Very thanks.
Regards,
Palani VS
|
|
|
|
|
I have a bitmap in my app that contains two icons.
I load the bitmap into an image list and associate it with a list control
During run time I set the bitmap list this
LV_ITEM lvItem;
lvItem.mask = LVIF_IMAGE;
lvItem.iItem = itemIndex;
lvItem.iImage = imageIndex;
m_listTest.SetItem(&lvItem);
where imageIndex is 0 or 1
In debug mode this works fine I can swap between icons no worries but in release mode I always get the icon at position 0 no matter what imageIndex is set to!
Im so sick of release problems with MFC. Can anyone help.
|
|
|
|
|
I'm currently trying to obtain some information about my mother board using WMI in VC++6. I've had a read of the MSDN documenation on the Win32_BaseBoard class but I'm still not sure of how WMI all works. Would someone who knows a bit about WMI please provide some code samples to get me started.
Much appreciated.
|
|
|
|
|
Here's one way:
HRESULT hr;
_variant_t v;
ULONG ulReturned;
DWORD dwAuthLevel;
IWbemLocator *pLocator;
IWbemServices *pService = NULL;
IEnumWbemClassObject *pEnum = NULL;
IWbemClassObject *pClass;
hr = CoCreateInstance(CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER, IID_IWbemLocator, (LPVOID *) &pLocator);
if (S_OK == hr)
{
hr = pLocator->ConnectServer(_bstr_t(L"root\\cimv2"), NULL, NULL, NULL, NULL, 0, NULL, &pService);
if (WBEM_S_NO_ERROR == hr)
{
hr = CoQueryProxyBlanket(pService, NULL, NULL, NULL, &dwAuthLevel, NULL, NULL, NULL);
hr = CoSetProxyBlanket(pService, RPC_C_AUTHN_DEFAULT, RPC_C_AUTHZ_NONE, NULL, dwAuthLevel, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE);
hr = pService->CreateInstanceEnum(_bstr_t("Win32_Baseboard"), WBEM_FLAG_RETURN_IMMEDIATELY | WBEM_FLAG_FORWARD_ONLY, NULL, &pEnum);
if (WBEM_S_NO_ERROR == hr)
{
do
{
hr = pEnum->Next(WBEM_INFINITE, 1, &pClass, &ulReturned);
if (WBEM_S_NO_ERROR == hr)
{
hr = pClass->Get(L"Caption", 0, &v, NULL, NULL);
if (VT_NULL != v.vt)
TRACE("Caption = %S\n", V_BSTR(&v));
hr = pClass->Get(L"ConfigOptions", 0, &v, NULL, NULL);
if (VT_NULL != v.vt)
{
LONG lBound;
BSTR Value;
SafeArrayGetUBound(V_ARRAY(&v), 1, &lBound);
while (lBound >= 0)
{
SafeArrayGetElement(V_ARRAY(&v), &lBound, &Value);
TRACE("ConfigOptions[%u] = %S\n", lBound, Value);
lBound--;
}
}
hr = pClass->Get(L"Depth", 0, &v, NULL, NULL);
if (VT_NULL != v.vt)
TRACE("Depth = %f\n", V_R4(&v));
pClass->Release();
}
} while (WBEM_S_NO_ERROR == hr);
pEnum->Release();
}
pService->Release();
}
pLocator->Release();
}
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|