passing a callback as function parameter

This is a discussion on passing a callback as function parameter within the C++ Programming forums, part of the General Programming Boards category; I have a dll that has a function that requires a callback to be pasted to it. But I get ...

  1. #1
    Registered User
    Join Date
    Aug 2004
    Posts
    731

    passing a callback as function parameter

    I have a dll that has a function that requires a callback to be pasted to it. But I get this error when I try it:

    Code:
    error: invalid conversion from `LRESULT' to `LRESULT (*)(HWND__*, UINT, WPARAM, LPARAM)'
    This is the function decloration:

    Code:
    void Engine::WindowCreate(HINSTANCE hinst, LRESULT CALLBACK WindowProcedure)
    Is it even possible to do what I want, if so how?

  2. #2
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    Maybe you want:
    Code:
    void Engine::WindowCreate(HINSTANCE hinst, WNDPROC WindowProcedure)
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  3. #3
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    hmm well I couldn't find that, guess I better search harder next time.

    thanks that worked.

  4. #4
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    Right, well it expected a pointer to a function and WNDPROC is typedef'ed as:
    Code:
    typedef LRESULT (*WNDPROC)(HWND,UINT,WPARAM,LPARAM);
    But don't ask me how I found that out. I used it in one of my programs but I don't remember where I found it first :P
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  5. #5
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    ooh ok ya I thought I needed a pointer but had no clue how to get one, ok I see thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 07-19-2008, 04:12 PM
  2. const at the end of a sub routine?
    By Kleid-0 in forum C++ Programming
    Replies: 14
    Last Post: 10-23-2005, 07:44 PM
  3. Passing file stream as function parameter
    By simonc2 in forum C++ Programming
    Replies: 6
    Last Post: 12-22-2004, 12:12 PM
  4. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 07:18 AM
  5. Replies: 2
    Last Post: 03-31-2002, 12:34 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21