|
Cedric Moonen wrote: 1) have data be a member of the class. But then, that doesn't make a lot of sense in the current scenario (why would you need to store it in the data pointer of the list control then ?)
What class? I can't see any class (other than CMyClass & CLIstCtrl) in the current scenario.
(just kidding)
Of course you're right with your observations since
fantasy1215 wrote: I'm unfamiliar to CListCtrl::SetItemData.
and I guess he is also unfamiliar with object lifetime management.
Thank you.
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.
[my articles]
|
|
|
|
|
Cedric Moonen wrote: 1) have data be a member of the class. But then, that doesn't make a lot of sense in the current scenario (why would you need to store it in the data pointer of the list control then ?)
To separate the order of the items in the control from that of the data in the control class. The control may display the items in numerous ways (alphabetical, numerical, ascending, descending, etc.) The data may not be ordered that way or convienient to do so. Nor does the data need to be a part of the list control class. It may be passed into the list control class to be acted upon but not reordered.
It mostly saves constantly looking up the item data.
However, I'm not sure if the CListCtrl item data value is guaranteed to be large enough to hold a pointer for all platforms.
YMMV
|
|
|
|
|
Thanks very much. After your reply, I know CListCtrl::SetItemData should store the Data which have the lifetime at least as long as your ListCtrl class(So you should make the data a class member of your ListCtrl class, or a heap data).
|
|
|
|
|
I'm writing a program with a login screen. In the login screen, a login and password has to be filled in. Now I want to read the login and password of the user the is logged in into windows (because the login and password giving into the program have to be exacly the same as those of windows)
|
|
|
|
|
sujtha wrote: Now I want to read the login and password of the user the is logged in into windows...
For the former, see GetUserName() .
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
(Sorry my system is having trouble pasting URLs)
http://msdn2.microsoft.com/en-us/library/kewsb8ba(vs.71).aspx
According to what it says, it will call ::operator new(size_t, char*, int) , but actually it gives a compilation error C2660: 'operator new' function does not take 3 arguments .
A* pa2 = new(__FILE__, __LINE__) A(20);
Maxwell Chen
|
|
|
|
|
At least they are honests
(It is at the top of the code snippet):
Anyway, it is also stated:
placement
Provides a way of passing additional arguments if you overload new.
hence you probably have to overload the operator to use additional placement argument.
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.
[my articles]
|
|
|
|
|
CPallini wrote: At least they are honests
// C2660 expected
Yes I have seen it.
If it gets a C2660, there wouldn't be a successful build and no chance to execute the call.
CPallini wrote: hence you probably have to overload the operator to use additional placement argument.
In the comment, it specifies the global operator new . I guess MSDN didn't intend to ask user implement an operator overload.
Anyway, it's fun to see a junk sample in MSDN.
Maxwell Chen
|
|
|
|
|
Maxwell Chen wrote: In the comment, it specifies the global operator new. I guess MSDN didn't intend to ask user implement an operator overload.
If the placement usage is for overloading, then overload is probably needed.
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.
[my articles]
|
|
|
|
|
If I remember rightly this is implemented in the STL so you need to include the right STL header to make this work #include <memory>
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Matthew Faithfull wrote: If I remember rightly this is implemented in the STL so you need to include the right STL header to make this work #include <memory>
Not working.
Maxwell Chen
|
|
|
|
|
Have you tried #include< new > ?
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Matthew Faithfull wrote: Have you tried #include< new > ?
Not working either.
Maxwell Chen
|
|
|
|
|
Hmm, I think I remember the example you're talking about and I remember struggling with it but I don't remember how to fix it, sorry.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
No doubt the article is poorly written. If you follow the links and read the grammer for the placement operator new you should come up with the following for the sample class (see following note below):
class A {
public:
A(int) { throw "Fail!"; }
void *operator new(size_t stAllocateBlock);
void *operator new(size_t stAllocateBlock, char chInit);
void *operator new(size_t stAllocateBlock, char*, int);
};
void *A::operator new(size_t stAllocateBlock)
{
void *pvTemp = ::malloc( stAllocateBlock );
return pvTemp;
}
void * A::operator new(size_t stAllocateBlock, char*, int)
{
void *pvTemp = ::malloc( stAllocateBlock );
return pvTemp;
}
void * A::operator new(size_t stAllocateBlock, char chInit)
{
void *pvTemp = ::malloc( stAllocateBlock );
if( pvTemp != 0 )
memset( pvTemp, chInit, stAllocateBlock );
return pvTemp;
}
If you compile this you will get the warning (C4291) that the article is trying to highlight. If you provide a placement new operator for a class you need to provide a matching delete operator.
|
|
|
|
|
Member 754960 wrote: If you follow the links and read the grammer for the placement operator new you should come up with the following for the sample class (see following note below):
Thanks!
Maxwell Chen
|
|
|
|
|
Can any one tell how to increase the font size in an statusbar
|
|
|
|
|
Use CWnd::SetFont() .
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
...formerly known as brahmma
Codeproject.com: Visual C++ MVP
|
|
|
|
|
I have created a Resource-only Dll viz. Language, which includes only resources i.e
Dialogs,
Toolbars,
Acceleraters,
Bitmaps,
Icons,
String Tables,
Version etc.
I have created one Dialog Based Application viz. LanguageApp, which includes only code - nothing else.
Now, I want to load each-n-every resource from the dll Language to application LanguageApp without including resource.h file of the dll.
<big>Provided that</big> : <big>Any modification done to dll should not cause application to build/compile again</big>
« Where There Is A Will There Is A Way »
|
|
|
|
|
So, what is your question here?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
...formerly known as brahmma
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Use the APIs FindResource and LoadResource .
Maxwell Chen
|
|
|
|
|
Punit Shah wrote: Provided that : Any modification done to dll should not cause application to build/compile again
Hence you cannot add resources to the DLL!
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.
[my articles]
|
|
|
|
|
CPallini wrote: Hence you cannot add resources to the DLL!
Indeed!
Maxwell Chen
|
|
|
|
|
Hi all,
I want to add two radio buttons to select two states, + or - option. How can I do that.
I've try this, add to radio buttons and add member variables to them as well. Then I want to get the user selected state from there and do my processing. But I've no luck to find it.
I appreciate your help all the time...
Eranga
|
|
|
|