Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Subclassing windows of other processes

Subclassing windows of other processes

Scheduled Pinned Locked Moved C / C++ / MFC
question
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    S O S
    wrote on last edited by
    #1

    Is it possible to subclass a window belonging to another process? If yes, then how?

    R 1 Reply Last reply
    0
    • S S O S

      Is it possible to subclass a window belonging to another process? If yes, then how?

      R Offline
      R Offline
      Ryan Binns
      wrote on last edited by
      #2

      Yes, but only by using a global hook. There is information on MSDN about how to do this. Basically you set a global hook (usually a WH_CBT hook) from inside a DLL and when the hook function is called by Windows for a particular process, your DLL is loaded into the address space of that process. You can then subclass whichever windows in that process you want. Usually, you set a hook that activates whenever the HCBT_CREATEWND code is passed (a window is created), but if the window is already created, you may never get the opportunity to subclass it. Ryan Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
      Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"

      S M 2 Replies Last reply
      0
      • R Ryan Binns

        Yes, but only by using a global hook. There is information on MSDN about how to do this. Basically you set a global hook (usually a WH_CBT hook) from inside a DLL and when the hook function is called by Windows for a particular process, your DLL is loaded into the address space of that process. You can then subclass whichever windows in that process you want. Usually, you set a hook that activates whenever the HCBT_CREATEWND code is passed (a window is created), but if the window is already created, you may never get the opportunity to subclass it. Ryan Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
        Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"

        S Offline
        S Offline
        S O S
        wrote on last edited by
        #3

        Thanks!

        R 1 Reply Last reply
        0
        • S S O S

          Thanks!

          R Offline
          R Offline
          Ryan Binns
          wrote on last edited by
          #4

          You're welcome :) Ryan Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
          Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"

          1 Reply Last reply
          0
          • R Ryan Binns

            Yes, but only by using a global hook. There is information on MSDN about how to do this. Basically you set a global hook (usually a WH_CBT hook) from inside a DLL and when the hook function is called by Windows for a particular process, your DLL is loaded into the address space of that process. You can then subclass whichever windows in that process you want. Usually, you set a hook that activates whenever the HCBT_CREATEWND code is passed (a window is created), but if the window is already created, you may never get the opportunity to subclass it. Ryan Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
            Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"

            M Offline
            M Offline
            MAAK
            wrote on last edited by
            #5

            Am not sure, but won't using WH_CALLWNDPROC or WH_CALLWNDPROCRET hooks to obtain the handle of the window or its controls after creation then using SetWindowLong() to set the GWL_WNDPROC property could do the job of subclassing the window after its creation?

            R 1 Reply Last reply
            0
            • M MAAK

              Am not sure, but won't using WH_CALLWNDPROC or WH_CALLWNDPROCRET hooks to obtain the handle of the window or its controls after creation then using SetWindowLong() to set the GWL_WNDPROC property could do the job of subclassing the window after its creation?

              R Offline
              R Offline
              Ryan Binns
              wrote on last edited by
              #6

              WH_CALLWNDPROC hooks are called from the context of the process that calls SendMessage(), not the one that receives the message. As long as a message is sent by the same process as the one you're wanting to subclass the window in, it should be OK. These will work, but these hook functions are called for every message sent to every window. They substantially slow down the system and are not recommended unless absolutely necessary. Ryan Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
              Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups