1 - Which is the preferred way of using the pointer symbol ?
for me, I like to declare every variable separatedly, and I don't like to mix declarations of different types.
this way, I prefer using int* pi; syntax because I see immediately that pi is of type int*.
Christian Flutcher wrote:
2 - Is it a good practice to append const with member function that doesn't modify any member variables?
definitely, yes !
because the one who write the class is not always the one who will use it, a class definition has to be clear, and has to mean what the class is designed for.
When you have an accessor which just does a "get", the it's obviously not modifying the object, and should be declared as const.
Christian Flutcher wrote:
I understand why const member functions exists. But if we are not planning to make the class object as constant,
humm, it seems to me that you don't fully understand the thing.
making a function member constant doesn't mean every function members have to be consts, and it doesn't mean either that the object will be used as a constant.
If you'd like to say that the object is used as a constant, then you would have to do like this :
2/ the question you ask is why I never mix those. And if the variable it at all significant, it gets its own line. I use long variable names - thanks to intellitext they're just as easy to type, and a lot easier to read. Only loop vars get bunched together. int i,j,k;
3/ I try to use const on member functions that *shouldn't* modify the state, not whether I think I might do so. It gives me the freedom to change my mind in one direction, and makes it harder to code mistakes in the other.
The next question is about catching all the SETTEXT message that are sent to a specific window:
I'm trying to hook all the settext messages that are sent to a specific window. The hook works almost perfectly, it intercepts all the settext messages and gets de windows handle stored in the pwp structure. pwp is a CWPRETSTRUCT type structure that contains the information of the SETTEXT hooked message.
The problem is that I can't get the text(caption) send to the window stored in the LPARAM of the settext hooked message (pwp->lParam. I only get garbage).
The idea is to get the text send to the window and save it to a file.
Im using a CallWndRetProc hook.
// globalvar contains the
// (unsigned int)window's handle I want to catch.
if (whandle == globalvar)
LPARAM l = pwp->lParam;
// The problem is on the next line.
// Var a only gets garbage.
a = (TCHAR *) l
fprintf(f1,"%d %s\n", whandle, a);
return CallNextHookEx(hook, nCode, wParam, lParam);