|
Ok, this problem is easy to solve. I suggest that you read the entire explanation with careful thought. By reading your reply, I must say that you have not completely understood how a filter function works. This explanation should help you out.
Go through the filter function again which resides in file 'HookDLL.cpp'. You can see that in this function, we get a pointer to the message structure in the lParam variable. This means, that the message - which was generated by some event X and is currently travelling towards the destined application - it's address is saved to the lParam variable. So, our first task is to acquire this pointer by doing a variable-to-pointer conversion. This is accomplished with
MSG* msg = (MSG*) lParam;
Ok, now our local variable msg is a pointer to a message structure. This structure is actually the message, which is passing towards the destined application. The message structure contains members which define the contents of the message. You can find the definition of this structure from MSDN here[^].
Like it says there, the member message of this structure contains the message identifier. Good, so, the next thing we do is that we check if this message is of type WM_CHAR . This is done here:
if ( msg->message == WM_CHAR )
{
...
}
As you can see, we use the msg pointer to access the message member of the MSG structure. Now, looking at the WM_CHAR definition in MSDN here[^], you can see that when a WM_CHAR message is posted, the wParam member specifies the character code (virtual key code) of the given key. For the virtual key codes list, see MSDN reference table here[^].
To access this member, we would need to use our pointer again. So let's do it:
UINT virtKeyCode = (UINT) msg->wParam;<DIV>
if ( virtKeyCode & VK_A )
{
}
if ( virtKeyCode & VK_B )
{
}
.. etc..
So, the problem you had back there, in your code, is that you look for the key code in the wrong place. Considering the filter function again, the key code DOES NOT reside in the local lParam variable found from the parameter list of the filter function. It resides in the wParam variable of the MSG structure, which's address is stored in the local lParam variable.
Once more:
1. The lParam variable in the parameter list of the filter function will contain the address of the MSG structure of the intercepted message
2. To access the message's contents, convert this variable to a MSG-pointer, and access the appropriate member of the structure as necessary.
In addition, remember that the key codes posted with WM_CHAR are VIRTUAL KEY CODES. For example, the 'A' key would be 'VK_A'. 'B' key would be 'VK_B'. See the above MSDN link for all these key codes listed in one table.
Hope this helps you out,
Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Sorry Sir I have done a small mistake and i corrected it after that
TCHAR testch = static_cast<tchar>( msg->wParam );
switch (testch)
{
case 'a':
I did this way and it worked and sorry for giving you trouble in way of wrongly implemented codings.
Any way it may be helpful for some young programmers like me in future to figure out they may go wrong here.
You have been one of the influencing person for me for i never seen anybody has so helping like you and i really appreciate your help for young students like me.
I really looking forward to your help further in my project and i try to do the project my self, the most but i will seek your help if i am in trouble.
I put this above comment in this forum to let other students like me to know who are the right persons to ask doubt for and who can provide you the right codings and idea for you.
Thank you very much sir,
vimal
|
|
|
|
|
Hello Sir
I need your help in these areas
1.I have created a dll and mapped into other applications and it changes the character what i want to send.
Now the problem i have is, i have to have a variable which is global to all the application.
Say for example i have a variable in dll
callled MYAPP
in my callback function i am checking
if (MYAPP=0)
{
Then do this process A
}
else(MYAPP=1)
{
Then do this process B
}
I have plan to change this variable MYAPP from my application as either
MYAPP= 0 for certain conditions
MYAPP=1 for certain conditions
Sir could you provide my some solutions how to declare this variable in dll and how i can use this varaible in my application to access that variable
I also need how to declare this varaible in header files also.
thanks in advance
|
|
|
|
|
Hello sir
in using wh_getmessage hook i have these problems
I need to type cast msg->wParam =VK_BACK
and post new characters using POSTMESSAGE api
problem i am having is if use postmessage then posted message 's character also coming again to my filter function
with the character code which i have send
ie say i type a then i type b , now i change b-> backspace and
postmessage(c ,b)
since i have changed b to backspace ,, the character which i posted ie c and b are also coming to filter function
since i dont change c to some other character no problem but since i have changed b to backspace the postmessage(b) also changes to backspace
how to prevent posted message not coming back to my filter function
i tried with a boolean but it dont work properly
so could you give me some idea sir how to implement this one
thanks in advance
with regards
vimal
|
|
|
|
|
Can any one please tell me how to create a Tree view for displaying directory structure in vc++.i want to create the tree view like a "windows explorer" program.
|
|
|
|
|
http://www.codeproject.com/useritems/drivebrowsingtree.asp
The World is getting smaller and so are the people.
|
|
|
|
|
Hi..
In c++ how can i create a new object of a class depending on the contents of the string. Suppose a function is there which takes input argument as a string which is nothing but a class name and that function will return me a new object of that class. something like...
char strClassName[] = "CTest";
CTest* pTest = new ??
now what will be replaced with ?? and i want to use that strClassName string.
class CTest is an example i can replace that with any class name. Whatever the class name appears in the strClassName that class's object should get created. Something like RUNTIME_CLASS macro in MFC. in this macro it uses ## to parsing token. Same thing i want to achieve not using MFC. how can i do that.
Thanks
Ravi
|
|
|
|
|
Its a simple use of logic i guess..
Class Class1 : public CBase
{
public:
void WhoAmI() //virtual fucntion in base class.
{
printf("i am class1");
};
};
Class Class2 : public CBase
{
void WhoAmI() //virtual fucntion in base class.
{
printf("i am class2");
};
};
char szClassName[] = "Class1";
void main()
{
CBase *pClass;
if(!strcmp(szClassName,"Class1"))
{
pClass = new Class1;
}
else
....
pClass->WhoAmI();
...
}
The World is getting smaller and so are the people.
|
|
|
|
|
It requires more thought that that. The RUNTIME_CLASS macro in MFC uses the runtime information gathered by MFC to create new objects.
In plain C++, the most effective approach would be to analyse the string the user has posted, and create a new object based on this info. For an example:
void* ptrObject = NULL;<DIV>
if ( _stricmp(strClassname, "CTest") == 0 )
{
ptrObject = reinterpret_cast<CTest*>(ptrObject);<DIV>
ptrObject = new CText(...);
}
<DIV>
... Use the object ...
<DIV>
delete ptrObject;
This code piece will analyze the input and create a new object based on the input. The void-pointer is used because we want the pointer to be global for the function, but we do not know it's type until we analyze the string. Be especially careful that you initialize the pointer to NULL before doing the cast conversion. Otherwise your compiler might throw you a warning.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
hi,
I'm a VietNamese student, now i'm doing a project with the ower-draw
control and I want to create a dialog that like your RGN Generator.
Would you please tell me how to create A RGN Generator text with the
burning fire around it and a button with the text circling it.
Thanks
|
|
|
|
|
Hello Guys,
Is it advisable to design a new control derived from CWnd like CButtons in stuff?
Can any one give me or direct me to a sample that has done it so that i can understand the complexity involved.
Thanx in advance.
Yo!
|
|
|
|
|
Search for CRulerWnd/ CRulerWindow in codeproject,which allows to create/use custom control Ruler(Scale)
Warm Regards,
KKR
|
|
|
|
|
Thanx Mate,
Regards,
Prakash.;)
The World is getting smaller and so are the people.
|
|
|
|
|
How can I crack an encryped *.zip file or an encrypted Word document? as we have known, decryption needs its algorithm and its key, but we don't know the encryption algorithm of it, I want to try the key one by one by using a hacker dictionary,
how can I do it? I want someone will help me~
I am a Chinese boy
|
|
|
|
|
Prolly wrong place to ask that question...
The word of the day is legs, let's go back to my house and spread the word
|
|
|
|
|
Hahaha man you are so sick...Password are put so that ppl like you dont read them.
|
|
|
|
|
don't put your nose into stinking things!
Don't try it, just do it!
|
|
|
|
|
ive used GetDIBits to get the bitmaps images RGB data into a
byte array
so effectively i can modify the rgb values of the image by just modifying the bits in the byet array buffer.
i tried creating a function
SetPixelColor(LPBYTE imgBuf,int column,int row,DWORD dwColor)
{
}
that is supposed to set the dwColor for pixel at row and column specified
however im having problems in mapping the row and column to the 1D LPBYTE buffer
please advice??
or is there any other alternative APIs
|
|
|
|
|
How can i change the text in the status bar for an SDI document >
|
|
|
|
|
try it !
probably
AfxGetApp()->m_hMainWnd->GetDescendWindow(yourstatusbarID);
Hello World!
|
|
|
|
|
I would like to write a proxy compatible with windows 98/XP.
I have looked at the articles here on CP and the two relevent articles don't apply to my particular problem I don't think.
For instance, the firewall example here on CP uses features specific to XP (I think). I want to write a firewall, but need it to work in win 98 also. Does anyone know of articles which might explain the different approaches used in writting a http proxy? basically I just want to capture HTML before being sent to browser, preferably both IE and Netscape. I have already considered using IWebBrowser2 to accomplish what I want to do also.
Edit Actually I really need to capture HTTP and HTML...so maybe IWebBrowser2 wouldn't work at all
Thanks
The word of the day is legs, let's go back to my house and spread the word
|
|
|
|
|
|
Coolness
Thanks
The word of the day is legs, let's go back to my house and spread the word
|
|
|
|
|
I want to design a windows program that can communicate using the serial port. I bought C#.net standard not knowing it did not have serial communcations framework and the work around is using MSComm.ocx from Visual Studio 6 which i do not have. Does C++.net standard have serial port communications framework? Or would buying Visual Studio.net solve my issue?
Thanks,
karl
|
|
|
|
|
For serial communication over COM port you have to use API functions like
CreateFile, WriteFile, ReadFile etc.
or alternatively you can use an OCX component, like MSComm.ocx.
Both ways can be achieved from C#, too.
Bunburry
|
|
|
|