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. AfxWndProc hook

AfxWndProc hook

Scheduled Pinned Locked Moved C / C++ / MFC
c++jsonquestion
4 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.
  • J Offline
    J Offline
    Joe4916
    wrote on last edited by
    #1

    Hi everyone ! Well, I have heard that the MFC runtime used a hook to dynamically link a component to its window procedure. I know that it's the best way to do it, but Microsoft itself advises the developers to use hooks in their applications only for debugging purposes, because it dramatically slows the programs down... What about MFC programs, are they much slower than their raw API equivalents ? Thanks in advance, Mark

    M R J 3 Replies Last reply
    0
    • J Joe4916

      Hi everyone ! Well, I have heard that the MFC runtime used a hook to dynamically link a component to its window procedure. I know that it's the best way to do it, but Microsoft itself advises the developers to use hooks in their applications only for debugging purposes, because it dramatically slows the programs down... What about MFC programs, are they much slower than their raw API equivalents ? Thanks in advance, Mark

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

      Well, as far as I know that MFC uses window subclassing to override the default WndProc. Hooking is usually used to install the MFC WndProc to the created window. I dont know what hooks exaclty, but definitely not WH_CALLWNDPROC hook or anything like it, which involve notification of frequent events. Usually WH_CBT is used, which can notify the hooking application about creation of windows. Another thing, there is a difference of local hooking used in this process and global hooking in which the hook is installed over the whole system. To sum up, the hooking is used just to initiate subclassing and it's local to the process. Subclassing doesnt degrade performance (actually it is done using APIs). So if there existed a degreade on performance of MFC application I think hooking wont be the reason. Am saying this with accordance to my knowledge, hope if there is anything wrong someone would correct it

      1 Reply Last reply
      0
      • J Joe4916

        Hi everyone ! Well, I have heard that the MFC runtime used a hook to dynamically link a component to its window procedure. I know that it's the best way to do it, but Microsoft itself advises the developers to use hooks in their applications only for debugging purposes, because it dramatically slows the programs down... What about MFC programs, are they much slower than their raw API equivalents ? Thanks in advance, Mark

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

        The hook that MFC uses is only installed for the time it takes to create the window. Basically, MFC installs the hook, creates the window, and uninstalls the hook. The hook has basically no influence on the program or the system. Incidentally, it's a thread-specific hook, so it would not slow down the system anyway. Hope this helps,

        Ryan

        "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
        • J Joe4916

          Hi everyone ! Well, I have heard that the MFC runtime used a hook to dynamically link a component to its window procedure. I know that it's the best way to do it, but Microsoft itself advises the developers to use hooks in their applications only for debugging purposes, because it dramatically slows the programs down... What about MFC programs, are they much slower than their raw API equivalents ? Thanks in advance, Mark

          J Offline
          J Offline
          Joe4916
          wrote on last edited by
          #4

          Thanks alot for your replies, mates !

          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