I was playing aroind with findwindow, and then i thought, "Is there a way to "attach" the WndProc of my program to the window i found?"
Since i got its handle, am i able to change the WndProc of the window pointed to by that handle?
Thanks
Printable View
I was playing aroind with findwindow, and then i thought, "Is there a way to "attach" the WndProc of my program to the window i found?"
Since i got its handle, am i able to change the WndProc of the window pointed to by that handle?
Thanks
I think that you can do it the same way you do with your own window handle like this:
Code:SetWindowLong(FOUND_WINDOW_HANDLE, GWL_WNDPROC, ThewindowProc)
No you can't!!!
This is because your program and the other one use different address spaces. In your program, whatever stands at 0x00827427 is not the same as in another program. Functions have addresses too, so a function of one program is only available to this program and no others.
There is a book from Microsoft Press called "Windows Programming for Experts" or something like this which discusses a way to do such things. It's very complicated, for example you have got to smuggle an unwanted dll into the other program.
If you try to insert your funciton into the other program, you will surely get an access violation.
As cornedbee said other apps can't acces the memory space of your app and vice versa. But both can acces the functions in a dll. So in order to subclass other windows (apps) you need to make a dll and to use hooks. Here is a messy example i made which subclasses the start button so when you click it with a mouse a message box pops up instead.
how to use it?
In the release folder there is a dll and an exe file. Run the exe and try to click the start button.
vlatko, apparently i can click the start button
what do you mean??Quote:
Originally posted by Amon Ra
vlatko, apparently i can click the start button
And that example uses MFC:D:rolleyes:
Well, the whole point of the example is in the DLL. In the exe there are a few lines of code, so i was lazy of makinf a whole win 32 app from scratch just for a few lines. Besides that it was only an experiment. When i make a serious app i surely won't use MFC (i don't know much MFC).Quote:
And that example uses MFC
I don't understand. It works fine for me and for many people i have sent it to. Go to the release folder where the exe and the dll are (both in the same release folder). Run the exe and a window will pop up. Now try to click the start button.Quote:
vlatko, apparently i can click the start button
What OS are you using?
windows 98
Me too. There shouldn't be a problem.
There is no problem with that. Compile the code,run it, and then click on the start button. It will show you a message box.
MY OS: Window 98 SE
Amon Ra sais he can click the start button.
So,what is the point?:D I can also click the start button;)
The point is that the start button is subclassed, on a WM_LBUTTONDOWN it pops up message box. To subclass other windows you need to put the wndproc into a dll so all apps can acces it. That is the point.:D
vlatko, i tried it again and it works.. =)
:rolleyes: OK :D :D