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. Callback and Assembly

Callback and Assembly

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialannouncement
5 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 van Leent
    wrote on last edited by
    #1

    As I have learned in the old days, it is impossible to have a CALLBACK within a class, this because of the "this" pointer. I usually wrote a static version, which redirected to the "real" function. Now I've come across another way to implement it using Assembly. However, I don't know how to accomplish this, and though I understand Assembly quite well, this is just something I can't work out. (Understanding is something else as doing.) Sjoerd van Leent LPCTSTR Dutch = TEXT("Double Dutch :-)");

    P J 2 Replies Last reply
    0
    • S S van Leent

      As I have learned in the old days, it is impossible to have a CALLBACK within a class, this because of the "this" pointer. I usually wrote a static version, which redirected to the "real" function. Now I've come across another way to implement it using Assembly. However, I don't know how to accomplish this, and though I understand Assembly quite well, this is just something I can't work out. (Understanding is something else as doing.) Sjoerd van Leent LPCTSTR Dutch = TEXT("Double Dutch :-)");

      P Offline
      P Offline
      Paul M Watt
      wrote on last edited by
      #2

      Look at the CWndProcThunk class accomplishes this in ATL. That should answer your questions for both x86 and Alpha implementations of this. Good Luck


      Build a man a fire, and he will be warm for a day
      Light a man on fire, and he will be warm for the rest of his life!

      S 1 Reply Last reply
      0
      • P Paul M Watt

        Look at the CWndProcThunk class accomplishes this in ATL. That should answer your questions for both x86 and Alpha implementations of this. Good Luck


        Build a man a fire, and he will be warm for a day
        Light a man on fire, and he will be warm for the rest of his life!

        S Offline
        S Offline
        S van Leent
        wrote on last edited by
        #3

        That is a good point, making it compatible for both x86 and Alpha platforms. LPCTSTR Dutch = TEXT("Double Dutch :-)");

        1 Reply Last reply
        0
        • S S van Leent

          As I have learned in the old days, it is impossible to have a CALLBACK within a class, this because of the "this" pointer. I usually wrote a static version, which redirected to the "real" function. Now I've come across another way to implement it using Assembly. However, I don't know how to accomplish this, and though I understand Assembly quite well, this is just something I can't work out. (Understanding is something else as doing.) Sjoerd van Leent LPCTSTR Dutch = TEXT("Double Dutch :-)");

          J Offline
          J Offline
          Joaquin M Lopez Munoz
          wrote on last edited by
          #4

          Although your thunk solution seems fine to me, if you're really wanting to pass a non-static member function as a callback, in some cases you can, if in a wildly non-portable manner. In this thread[^] I explain the method. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

          S 1 Reply Last reply
          0
          • J Joaquin M Lopez Munoz

            Although your thunk solution seems fine to me, if you're really wanting to pass a non-static member function as a callback, in some cases you can, if in a wildly non-portable manner. In this thread[^] I explain the method. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

            S Offline
            S Offline
            S van Leent
            wrote on last edited by
            #5

            Well, the problem rests that I want to interact with the Windows API, so I don't think the API let's me do this (though it is a beauty) :). Sjoerd van Leent LPCTSTR Dutch = TEXT("Double Dutch :-)");

            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