Callback and Assembly
-
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 :-)");
-
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 :-)");
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! -
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!That is a good point, making it compatible for both x86 and Alpha platforms. LPCTSTR Dutch = TEXT("Double Dutch :-)");
-
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 :-)");
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 -
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 DesarrolloWell, 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 :-)");