Results 1 to 18 of 18

Thread: WndProc

  1. #1

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500

    Question WndProc

    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
    Amon Ra
    The Power of Learning.

  2. #2
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    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)
    Baaaaaaaaah

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  4. #4
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    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.
    Attached Files Attached Files
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    how to use it?
    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.

  6. #6
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    In the release folder there is a dll and an exe file. Run the exe and try to click the start button.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  7. #7

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500

    hmmm

    vlatko, apparently i can click the start button
    Amon Ra
    The Power of Learning.

  8. #8
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    Re: hmmm

    Originally posted by Amon Ra
    vlatko, apparently i can click the start button
    what do you mean??
    Baaaaaaaaah

  9. #9
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    And that example uses MFC
    Baaaaaaaaah

  10. #10
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    And that example uses MFC
    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.

    What OS are you using?
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  11. #11

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500

    ...

    windows 98
    Amon Ra
    The Power of Learning.

  12. #12
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Me too. There shouldn't be a problem.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  13. #13
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    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
    Baaaaaaaaah

  14. #14
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Amon Ra sais he can click the start button.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  15. #15
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    So,what is the point? I can also click the start button
    Baaaaaaaaah

  16. #16
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    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.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  17. #17

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500

    ahhh

    vlatko, i tried it again and it works.. =)
    Amon Ra
    The Power of Learning.

  18. #18
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    OK
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width