|
Look under "Hooks" on the MSDN Index, you will have different types of Hooks, Keyboard Hooks are for you.
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
Ahhhh, that hurts. How can I get it to log for the entire system and not just one program (I have never used hooks)
"To wonder is to begin to understand"
|
|
|
|
|
Actually System Hooks are for the entire system, not just one program.
I don't remember the details about the use (I have used them a little bit a long time ago), but you can capture pretty much anything (you won't be able to get the keyboard entry for de logon process, and that kind of stuff).
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
I'm reading a up to hundred CStrings from a file that I would like to load in memory and for each CString, have an associated integer with it so that everytime I access the CString I add 1 to the integer. Just like a list control would work with the associated DWORD for the item data. I have looked in to CList and CArray but not sure if those would be best for what I need to do. What would be the best way of doing this?
|
|
|
|
|
MFC container classes were written as a sropgap while STL was finalised. You should use STL over MFC container classes.
What you need here is map. A map is an associative container, so for example
map<cstring, int=""> m_map;
means that you use CStrings to index a list of integers. You can add CStrings to the list like this:
m_map["My String, could equally be a CString variable"] = 1;
Then you can add to the value like this:
m_map["My String, could equally be a CString variable"]++;
Finally, you can iterate through the list like this:
map<cstring, int="">::iterator it = m_map.begin();
for (;it != m_map.end; ++it)
{
AfxMessageBox(it.first()); // Just shows all the strings in message boxes
}
This is off the top of my head, I may have made a typo here or there, but it's fundamentally correct AFAIK.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Thank you Christian! Thats exactly what I need. For some reason I still shy away from ATL.
One more thing. Would it be possible for me to do the same in lets say Linux/Unix?
|
|
|
|
|
Did you mean ATL ? I've actually put a lot of time into ATL recently and found once it starts to gel it is very cool stuff, but that is an aside. STL is nothing to do with ATL, and it is part of the C++ standard, one of the many reasons I prefer it to MFC containers. Yes, anywhere you have C++ by definition you will have STL containers and algorithms.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Yes your correct, STL is what I meant. STL looks to be pretty cool for collection classes. I'm looking into ATL for something new to rack my mind with and got the two mixed up.
Jay
|
|
|
|
|
Well, you're looking in the right place. I read books on ATL for almost a year before I came up with a project as an excuse to start coding. ATL Internals says that most people spend about six months in the dark with ATL until one day the light comes on and they start to see exactly how it fits nad why it is so cool. That was certainly the case with me.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Is there a way to get the value of each string also? I have been looking through MSDN and havn't found anything about that.
|
|
|
|
|
MSDN does not provide much good STL info. You can step through a map using iterators, like this:
map<CString, int>::iterator it = m_MyMap.begin();
for (;it != m_MyMp.end(), ++it)
{
CString s = it->first();
}
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Thank you Christian! Just ran into it searching through yahoo also.
|
|
|
|
|
Don't know why I thought about STL before. I'm loading the whole file into memory and searching for each occurance of a few key words on each access. One thing I found is that you can use a map of vectors, list, etc. which seems alot better, faster and easier.
ATL I'm still lost.
|
|
|
|
|
For ATL I ended up so stuck I bought 'Teach yourself ATL in 24 hours'. Once I read that I had the basics I needed to tackle ATL Internals. Just stick with it, I also read for months when I had no time to play with code, and eventually it all gelled.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
I'd need to create a Property list, like that in Visual Studio for C++ and VB...
You all know the Properties window that is basically a two column grid but that lets you set properties on controls and the like.
Has anyone written a class (or is there one?) for and MFC app that will show up in a dockable window?
I don't need a property sheet...which is all I can seem to find...
I actually need something EXACTLY like the one in Visual Studio
ideas?
thanks
mike
|
|
|
|
|
Look in the List Control section here on CodeProject, I was just there.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
I have got a template class. It's called ObArray and one of the datamembers are a pointer to an array of any type of object. At the moment ObArray is just constructing all the objects using the default constructor.
But I always want to have the option to use another constructor to initialize the objects, not just the default one. I want this because it's faster than first creating the objects using te deafult constructor, and then change all the objects. Another reason is that not all classes even have a default constructor, which makes it impossible to create an array of instances of those classes.
The only way I can imagine this to be solves is by sending the constructin info along with the constructing of the array object (ObArray). Since constructors of course take a variable number of arguments, the constructor of ObArray must accept that too.
Like 'ObArray<t>::ObArray(int initLen, ...)', and then this constructor sends the arguments along to the constructor of each of the objects. Is this possible in any way?
Sprudling
|
|
|
|
|
Like 'ObArray::ObArray(int initLen, ...)', and then this constructor sends the arguments along to the constructor of each of the objects. Is this possible in any way?
No. Use placement new instead.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Uhm... I don't really understand what you mean.
I know I can't actually write 'ObArray::ObArray(int initLen, ...)'. I just meant that this constructor could take arguments like that, and pass them on...
Btw... I think I found some sort of solution by using copy constructors, but that requires that the class I want to create the array of has one.
Another solution not requiring that will be better.
Sprudling
|
|
|
|
|
I mean that you should allocate raw memory for all objects first using ::operator new or malloc. Constructors are not called in this phase. You use placement new next to initialize objects in allocated memory. The only problem left is that different classes you're going to put into ObArray may need different number of constructor parameters - you can solve this by providing multiple ObArray constructors, each having different number of params. Assuming that there are max 3 parameters that you need to pass, declaration of ObArray should begin like this:
template <typename T,
typename P1 = void,
typename P2 = void,
typename P3 = void>
class ObArray
{
};
Of course, you can generalize this to use more than 3 parameters in the c'tor.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hi...
How can I convert an Integer to LPSTR
here is what I want:
TextOut(hdc, 20, 20, Integer, 5);
|
|
|
|
|
With itoa(nVal, buff, 10);
Where buff is a LPSTR and nVal is a Integer.
Cheers!!!!
Carlos Antollini.
|
|
|
|
|
|
I looked everywhere and tried alot of different things, but I can't
find any code that will help me create a multiline CListCtrl in
report mode. Any ideas? Any suggetsions? Any code?
Any response any one can give me will be greatly appreciated.
Sincerely,
Danielle (an overworked graduate student)
|
|
|
|
|
Its possible.
http://www.codeguru.com/listview/ReportCtrl.shtml
Bret Faller
Odyssey Computing, Inc.
|
|
|
|