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
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.
All the buzzt CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
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.
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).
vlatko, apparently i can click the start button
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.
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.