|
inline int CompareNoCase(LPCWSTR lpsz) const
{
// ignore case
return _wcsicmp(m_pchData, lpsz);
} // MBCS/Unicode aware
is what the definition of the CompareNoCase function that can be found in chstring.h file.
So aren't we passing a char * to this function.
Vision is Always important and so is your ATTITUDE.
Wishes.
Anshuman Dandekar
|
|
|
|
|
I think you are missing the important point: we are not discussing about char arrays (so something like char* MyArray or char MyArray[5] ) but about CString classes (MFC classes), which is a huge difference. The CString class has an overloaded == operator (take a look at the link I supplied).
|
|
|
|
|
The == operator internall use the compare function
see the implementaion of operator==
_AFX_INLINE bool AFXAPI operator==(const CString& s1, const CString& s2)<br />
{ <br />
return s1.Compare(s2) == 0; <br />
}
so if wants to know if two strings are equal using compare function u have use like this
if( Str1.Compare( Str2) == 0 )<br />
{<br />
}
nave
|
|
|
|
|
I saw this coding in one sample...
My doubt is already "this" is a pointer.then why they use another pointer in this.
CTrans & CTrans::operator=(CTrans dData)
{
m_bClose = dData.m_bClose;
m_sData = dData.m_sData;
return *this;
}
|
|
|
|
|
This function is like a constructor where the values being passed are copied into the variables of the object with which this constructor is called.
So to reflect all the changes properly you need to take the values into a pointer and return 'this' for the same.
Vision is Always important and so is your ATTITUDE.
Wishes.
Anshuman Dandekar
-- modified at 9:29 Friday 5th May, 2006
|
|
|
|
|
Anu_Bala wrote: My doubt is already "this" is a pointer.then why they use another pointer in this.
It's because it is returning a reference so *this is required. This is called De-Referencing .
If the function was modified as follows
CTrans* CTrans::operator=(CTrans& dData)
{
...
return this;
}
This means we are passing the address of this class. Hence no *this is required.
Nibu thomas
Software Developer
Faqs by Michael dunn
|
|
|
|
|
i don't exactly understand your problem (english speaking i think), but here is what i can say about the subject :
in C++, each member function (the functions declared within a class receive an implicit parameter : the this pointer. here is why...
when you do such thing, the function has to know on which instance it works on :
CMyObject o1, o2;
o1.Foo();
how does the Foo() function know it works on the o1 instance, instead of o2, or even instead of any CMyObject object ? the solution : this .
the this type is a pointer to the class (here CMyObject* ), and can be also set to const if the function is declared as a const member (like void Foo(void) const; ).
once you know that, the question is "why does the operator= return *this ?"
here is the tip. you know that C++ allow such statements :
int a, b, c;
a = b = c = 1;
so the behavior should also be reproduced with classes :
CMyObject o1, o2, o3;
o1 = o2 = o3 = ;
which is equivalent to :
CMyObject o1, o2, o3;
o1.operator=(o2.operator=(o3.operator=( )));
the only way to do this is that each operator= return a reference to the object it has just altered so that the other operator= can get its new modified state.
do you understand better with this ?
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
How to sort the rows of CListCtrl depanding upon Particular column. Or Please tell me how to use CListCtrl::SortItems function for sorting.
|
|
|
|
|
Hi Anil,
you need to create a callback function that will be called each time the two items in the list control need to be compared.
int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2,
LPARAM lParamSort);
BOOL SortItems(
PFNLVCOMPARE pfnCompare,
DWORD_PTR dwData
);
Pass a pointer to the sort items function for the callback function.
Vision is Always important and so is your ATTITUDE.
Wishes.
Anshuman Dandekar
|
|
|
|
|
_AnShUmAn_ wrote: BOOL SortItems(
PFNLVCOMPARE pfnCompare,
DWORD_PTR dwData
);
The above function internally sends the LVM_SORTITEMS message.. I found the LVM_SORTITEMSEX message is more easy to use than LVM_SORTITEMS .
U can use ListView_SortItemsEx Macro to send LVM_SORTITEMSEX message
nave
|
|
|
|
|
anilksingh wrote: How to sort the rows of CListCtrl depanding upon Particular column.
Provide a HDN_ITEMCLICK handler. In that handler function, the column that was clicked is:
HD_NOTIFY *phdn = (HD_NOTIFY *) pNMHDR;
m_nSortColumn = phdn->iItem; Now call SortItems() .
anilksingh wrote: Or Please tell me how to use CListCtrl::SortItems function for sorting.
Be sure to call SetItemData() when adding items to the list control.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
Hi all,
I found out that when an application spools another application, the child application inherits some of the attributes of parent such as, security attributes, process attributes etc..
Is there any way to remove all this inherited attributes? So that it runs as if it was launched from the explorer.I want to do it from the child application
nave
|
|
|
|
|
Naveen R wrote: Is there any way to remove all this inherited attributes?
Are they inherited by the child process? Are you sure?
Nibu thomas
Software Developer
Faqs by Michael dunn
|
|
|
|
|
Nibu thomas wrote: Are you sure?
yes..
In my case there is a service.. From that service it executes another application(Child application). Since services have several limitations, all that limitation gets applicable to the child application also. I want to get ride of it..
Any way?
nave
|
|
|
|
|
Naveen R wrote: Is there any way to remove all this inherited attributes?
Sure. Several of the arguments to CreateProcess() do just that.
Naveen R wrote: I want to do it from the child application
Do what?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
Thanks David Crow,
I am in situation that I cannot modify the binary of the exe the calls CreateProcess(). But I can change the Child application( the application that is been created using Createprocess).
DavidCrow wrote: Do what?
I want to remove the parent property inheritance from the child application. I want to write that code in Child application.
nave
|
|
|
|
|
Naveen R wrote: I want to remove the parent property inheritance from the child application. I want to write that code in Child application.
To my knowledge, there is no parent/child relationship when creating processes. A "child" process is on its own as soon as its created, and the "parent" can immedialtely be shut down without any ramifications to the "child." Those arguments that are passed to CreateProcess() are just used to get the process started. Onced started, that process is free to change them to other values.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
In my case there is a service.. From that service it executes another application(Child application). Since services have several limitations, all that limitation gets applicable to the child application also. I cannot even interact with the desktop from the child process.
Plz tell me how to change this behaviour
nave
|
|
|
|
|
Hello,
I have a file representing the content of a chipcard. I want to integrate this data in my EXE, without referencing an external file. I try to create a user defined binary resource. But how can I paste the content of the file in the binary resource editor of Visual Studio 7.1?
Thanks in advance for your hint!
|
|
|
|
|
Nolyann wrote: But how can I paste the content of the file in the binary resource editor of Visual Studio 7.1?
Thanks in advance for your hint!
Just put the data in a file, add a RCDATA type into the .rc file like:
IDR_RC_DATA1 RC_DATA DISCARDABLE "c:\\folder\\file.dat"
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
Thanks David for your answer.
But in this case the file file.dat has to be delivered with the EXE file of the application, and I would avoid that.
I use another method, until someone gives a better suggestion : since I can save the chipcard data in hex representation I declare a char array initialised with this data. But I hoped there is a quicker way using the resources...
|
|
|
|
|
Nolyann wrote: But in this case the file file.dat has to be delivered with the EXE file of the application, and I would avoid that.
Ok, see if this article helps.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
Hi David,
I read your article with interest, but I decided to keep the solution of defining an array initialised with the binary data I want to embed, which I find simpler for my goal.
Thanks for your answers again.
|
|
|
|
|
1)When I add following statements in my code =>
IMpeg2Data *pMPEG = NULL;
hr = pMPEG2Demux->QueryInterface(IID_IMpeg2Data,(void**)&pMPEG);
it is giving me error as follows =>
Linking...
aDlg.obj : error LNK2001: unresolved external symbol _IID_IMpeg2Data
Debug/a.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Creating browse info file...
What should i do? Is there any library missing. I have added libraries "Strmiids.lib Quartz.lib Dmoguids.lib" & also i have added "#include <mpeg2data.h>" header file.
2)When i tried to add following statement =>
IMpeg2PsiParser* pMpeg2Psi;
it is giving error as =>
error C2065: 'IMpeg2PsiParser' : undeclared identifier
|
|
|
|
|
My question is quite simple but I can't solve it. I have create a socket tcp, how can I know when the socket go down due to external cause?
For example when the network is down etc....
Use members like CAsynchSocket::OnClose, isn't correct because this member is called only when my application close the socket!
...however how can i do?
Thanks to all!!
|
|
|
|