Results 1 to 4 of 4

Thread: [RESOLVED]Callback Type Problem

Threaded View

  1. #1

    Thread Starter
    Addicted Member Max_aka_NOBODY's Avatar
    Join Date
    Jul 2004
    Location
    Amman, Jordan
    Posts
    179

    Resolved [RESOLVED]Callback Type Problem

    First off, I'm a newbie C++ coder, so I'm sorry if what I'm asking is obvious, but searching has given me no solution. I'm trying to write a simple window class with the message handler passed by the class user, so I define a member variable as "LRESULT(*)(HWND, UINT, WPARAM, LPARAM)", which is supposed to be the function pointer. Then I assign the passed value(same type) to this member, which results in the error: "invalid conversion from `LRESULT (*)(HWND__*, UINT, WPARAM, LPARAM)' to `LRESULT (*)(HWND__*, UINT, WPARAM, LPARAM)'". I read that it could be caused by the function address being that of a non-static member function, but I've tried both a normal function and a member, and both result in the same error.

    Here's the code that concerns this problem(it's scattered around a few files, but that's unimportant I think all are linked by inclusion):
    PHP Code:
    typedef LRESULT(*grCallbackWndProc)(HWNDUINTWPARAMLPARAM);

    LRESULT CALLBACK MessageHandler(HWND hWndUINT iMessageWPARAM wParamLPARAM lParam);

    grErrorCode grWindow::Create(HINSTANCE hInstance,
                           
    grCallbackWndProc WndProc,
                           
    LPSTR sTitle,
                           
    int iWidth,
                           
    int iHeight,
                           
    int iStyle) {
            if (
    == WndProc) {
                
    //This line gives the error.
                
    mWndProc = &MessageHandler;
            } else {
                
    mWndProc WndProc;
            }
            
    //Rest of code that compiles fine.

    This is using the GCC compiler.

    Thanks for any insight.
    Last edited by Max_aka_NOBODY; May 9th, 2006 at 07:59 AM.
    Please, put a checkmark ( ) or the word [RESOLVED] in your topic title if it was resolved, and rate the person who resolved it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width