CALLBACK problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mohamed Fysal

    CALLBACK problem

    I have written a Regular DLL with many Export Functions and one CALLBACK fun
    ction .


    The callback function declared in the .cpp file of the Regular DLL is as fol
    lows:

    typedef BOOL (CALLBACK* ExProcessMessag e)(UINT msg, LPVOID lpParam);
    //
    ExProcessMessag e MyProcMsg;

    ----------------------------------------------------------------------------
    --------------------

    I have written an MFC Application which is dynamically linked to this Regula
    r DLL.

    In the MFC Application (SDI Application with DOC/VIEW support) , I also use
    threading functionalities .

    In the MFC Application I have declared a global function as a CALLBACK funct
    ion as follows:


    BOOL CALLBACK OnCMFMessage(UI NT msg, LPVOID lpParam1);



    I initilaise the address of this function to the pointer varaible declared i
    n DLL (MyProcMsg) as follows in my MFC App code:


    InitializeCB((l ong)&OnCMFMessa ge); -- (whereas the InitializeCB is a export
    function in DLL to initialise the callback function pointer)



    ----------------------------

    Now the problem is , when I call the CALLBACK function (OnCMFMessage) from m
    y DLL by using the function pointer , the callbcak function is not at all ca
    lled. What could be the reason?????

    But when I use the as said above with a Win32 application, it worked fine. M
    y callbcak is called. And I got the desired result.
    The problem was only with the MFC App which I said above.


  • Victor Bazarov

    #2
    Re: CALLBACK problem

    Mohamed Fysal wrote:[color=blue]
    > I have written a Regular DLL with many Export Functions and one CALLBACK fun
    > ction .[/color]

    DLLs are off-topic here. Just so you know...
    [color=blue]
    > The callback function declared in the .cpp file of the Regular DLL is as fol
    > lows:
    >
    > typedef BOOL (CALLBACK* ExProcessMessag e)(UINT msg, LPVOID lpParam);
    > //
    > ExProcessMessag e MyProcMsg;[/color]

    That's not a function. That's a pointer to a function. It is left
    uninitialised.
    [color=blue]
    > ----------------------------------------------------------------------------
    > --------------------
    >
    > I have written an MFC Application which is dynamically linked to this Regula
    > r DLL.[/color]

    MFC is off-topic here.
    [color=blue]
    > In the MFC Application (SDI Application with DOC/VIEW support) , I also use
    > threading functionalities .[/color]

    Threading is off-topic here.
    [color=blue]
    > In the MFC Application I have declared a global function as a CALLBACK funct
    > ion as follows:
    >
    >
    > BOOL CALLBACK OnCMFMessage(UI NT msg, LPVOID lpParam1);[/color]

    OK.
    [color=blue]
    > I initilaise the address of this function to the pointer varaible declared i
    > n DLL (MyProcMsg) as follows in my MFC App code:
    >
    >
    > InitializeCB((l ong)&OnCMFMessa ge); -- (whereas the InitializeCB is a export
    > function in DLL to initialise the callback function pointer)[/color]

    Whatever. Since you don't provide the contents of 'InitializeCB', you
    could simply not mention it. There is no proof here that initialisation
    of your "address of this function" actually works. Or that it doesn't.
    [color=blue]
    > ----------------------------
    >
    > Now the problem is , when I call the CALLBACK function (OnCMFMessage) from m
    > y DLL by using the function pointer , the callbcak function is not at all ca
    > lled. What could be the reason?????[/color]

    The reason could be that your 'InitializeCB' doesn't work very well.
    The reason could be that your function is never defined. Or there can
    be a whole host of other reasons. Since you provided no substantial
    amount of code to illustrate your problem, nothing can be said or done.
    [color=blue]
    > But when I use the as said above with a Win32 application, it worked fine. M
    > y callbcak is called. And I got the desired result.
    > The problem was only with the MFC App which I said above.[/color]

    If you think that MFC is the root of the problem (at least you make it
    sound that it might be), try an MFC newsgroup, one of (or all):

    comp.os.ms-windows.program mer.tools.mfc
    microsoft.publi c.vc.mfc

    If you think that your function's place in a DLL is a problem (which it
    might be as well), try the newsgroup for your os programming:

    comp.os.ms-windows.program mer.win32

    V

    Comment

    Working...