Click here to Skip to main content
15,915,508 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Again a callback question... m(__)m Pin
Lim Bio Liong13-Feb-02 16:28
Lim Bio Liong13-Feb-02 16:28 
GeneralRe: Again a callback question... m(__)m Pin
Mr.Freeze13-Feb-02 17:05
Mr.Freeze13-Feb-02 17:05 
GeneralRe: Again a callback question... m(__)m Pin
Lim Bio Liong13-Feb-02 18:08
Lim Bio Liong13-Feb-02 18:08 
GeneralRe: Again a callback question... m(__)m Pin
Mr.Freeze13-Feb-02 19:15
Mr.Freeze13-Feb-02 19:15 
GeneralRe: Again a callback question... m(__)m Pin
Lim Bio Liong13-Feb-02 22:58
Lim Bio Liong13-Feb-02 22:58 
GeneralRe: Again a callback question... m(__)m Pin
Mr.Freeze14-Feb-02 13:17
Mr.Freeze14-Feb-02 13:17 
GeneralRe: Again a callback question... m(__)m Pin
Lim Bio Liong14-Feb-02 20:54
Lim Bio Liong14-Feb-02 20:54 
GeneralRe: Again a callback question... m(__)m Pin
Joaquín M López Muñoz13-Feb-02 21:15
Joaquín M López Muñoz13-Feb-02 21:15 
In one of your posts following this, you said you've declared a shared data segment. Keep it, you will need it for what you're after.
The trick is having a function pointer storing the callback in the shared data segment:
// in the DLL header
typedef BOOL (WINAPI * MY_DLL_CALLBACK)(int); // or whatever signature you want to use
// in the DLL .cpp
#pragma data_seg(".MYSEC")
MY_DLL_CALLBACK pMyDLLCallback=0;
#pragma dara_seg()
Now you just export functions setting and using this pointer:
extern "C" __declspec(dllexport) void setCallback(MY_DLL_CALLBACK *pCallback)
{
  pMyDLLCallback=pCallback;
}

extern "C" __declspec(dllexport) BOOL callCallback(int parm1)
{
  return pMyDLLCallback(parm1);
}
Having the pointer declared in a shared data segment is required so that both apps "see" the same variable (by default, EXEs have their own copy of all the data in DLLs, regardless of whether the DLLs are being used by other apps).

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
GeneralRe: Again a callback question... m(__)m Pin
Lim Bio Liong13-Feb-02 22:46
Lim Bio Liong13-Feb-02 22:46 
GeneralRe: Again a callback question... m(__)m Pin
Joaquín M López Muñoz13-Feb-02 23:24
Joaquín M López Muñoz13-Feb-02 23:24 
GeneralRe: Again a callback question... m(__)m Pin
Lim Bio Liong13-Feb-02 23:52
Lim Bio Liong13-Feb-02 23:52 
GeneralRe: Again a callback question... m(__)m Pin
Mr.Freeze14-Feb-02 13:22
Mr.Freeze14-Feb-02 13:22 
GeneralImageList_Draw not working under XP Pin
David Wengier13-Feb-02 14:13
David Wengier13-Feb-02 14:13 
GeneralRe: ImageList_Draw not working under XP Pin
Tim Smith13-Feb-02 14:47
Tim Smith13-Feb-02 14:47 
GeneralRe: ImageList_Draw not working under XP Pin
David Wengier13-Feb-02 15:00
David Wengier13-Feb-02 15:00 
GeneralRe: ImageList_Draw not working under XP Pin
Tim Smith14-Feb-02 2:21
Tim Smith14-Feb-02 2:21 
GeneralRe: ImageList_Draw not working under XP Pin
Shog913-Feb-02 18:19
sitebuilderShog913-Feb-02 18:19 
GeneralRe: ImageList_Draw not working under XP Pin
David Wengier13-Feb-02 18:46
David Wengier13-Feb-02 18:46 
GeneralRe: ImageList_Draw not working under XP Pin
Shog914-Feb-02 6:59
sitebuilderShog914-Feb-02 6:59 
Generaldevstudio6 sub-projects only showing up for "debug" and "release" configs Pin
Jason De Arte13-Feb-02 11:46
Jason De Arte13-Feb-02 11:46 
GeneralRe: devstudio6 sub-projects only showing up for "debug" and "release" configs Pin
Tim Smith13-Feb-02 12:39
Tim Smith13-Feb-02 12:39 
GeneralGDI+ in ATL Control Pin
pattyweb13-Feb-02 10:39
pattyweb13-Feb-02 10:39 
GeneralNeed help with Regular expression replace Pin
Stephane Routelous13-Feb-02 10:18
Stephane Routelous13-Feb-02 10:18 
GeneralRe: Need help with Regular expression replace Pin
Michael Dunn13-Feb-02 10:43
sitebuilderMichael Dunn13-Feb-02 10:43 
GeneralRe: Need help with Regular expression replace Pin
moliate13-Feb-02 10:45
moliate13-Feb-02 10:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.