CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Oct 2001
    Posts
    745

    Send Message Problem

    Hi,

    Have a class which is derived from CDialog.

    Have given this in the Header & the corresponding declaration in the .cpp of the class



    LRESULT SendMessage(UINT message,WPARAM wParam = 0 );


    I get this error while compiling the .cpp
    error C2511: 'SendMessageW' : overloaded member function 'int (unsigned int)' not found in ...

    My project is uncode defined...
    Can I put this function using the class wizard,If yes,which message in class wizard..

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430
    Why are you trying to implement your own function with the same name (and almost the same parameters) as a standard API SendMessage ?
    What does your own SendMessage have to do?

  3. #3
    Join Date
    Feb 2002
    Posts
    3,788
    Quote Originally Posted by Kohinoor24
    Hi,

    Have a class which is derived from CDialog.

    Have given this in the Header & the corresponding declaration in the .cpp of the class



    LRESULT SendMessage(UINT message,WPARAM wParam = 0 );


    I get this error while compiling the .cpp
    error C2511: 'SendMessageW' : overloaded member function 'int (unsigned int)' not found in ...

    My project is uncode defined...
    Can I put this function using the class wizard,If yes,which message in class wizard..

    there is no problem!!! with SendMessage. The problem is that you won't even open MSDN to see what prototype this function has. if you would have done it you would have known that this is the correct fucntion prototype:
    Code:
    LRESULT SendMessage( UINT message, WPARAM wParam = 0, LPARAM lParam = 0 );
    It has nothing to do with your project being UNICODE as well.
    And no, you cannot put this function using class wizard for the simple reason that it doesn't exist there!

    As a conclusion I would advise you to start learning/reading a bit about MFC and clarify some of the things, because it can be clearly seen that you hardly have an idea of what you're suppose to do. No offense!

  4. #4
    Join Date
    Mar 2003
    Location
    India {Mumbai};
    Posts
    3,871
    Actually, depending on Unicode and non-unicode mode 'SendMessage' is #defined as either SendMessageA or SendMessageW. Here, if you strongly need to use that same name, you need to #undef SendMessage. After doing that, you may see many and many of the errors.

    So, its better to rename the method in your class.
    My latest article: Explicating the new C++ standard (C++0x)

    Do rate the posts you find useful.

  5. #5
    Join Date
    Oct 2001
    Posts
    745
    you are right in that Iam new to MFC. I made this post after looking into MFC.I saw these same parameters,I reduced it to 2 paramters co's
    When I used
    My class::SendMessage(..It showed here only 2 parameters.

    Thanks for ur advice....

  6. #6
    Join Date
    Feb 2002
    Posts
    3,788
    Quote Originally Posted by Ajay Vijay
    Actually, depending on Unicode and non-unicode mode 'SendMessage' is #defined as either SendMessageA or SendMessageW.
    ..nevertheless, the different naming doesn't affect the number of parameters, which is what i said.

  7. #7
    Join Date
    Mar 2003
    Location
    India {Mumbai};
    Posts
    3,871
    Quote Originally Posted by Alin
    ..nevertheless, the different naming doesn't affect the number of parameters, which is what i said.
    File: WINUSER.H
    Line: 2524
    VS6
    Code:
    #ifdef UNICODE
    #define SendMessage  SendMessageW
    #else
    #define SendMessage  SendMessageA
    #endif // !UNICODE
    Got it??

    I also present simple example:
    Code:
    #define if main
    void if()
    {
    printf("Hello World!");
    }
    My latest article: Explicating the new C++ standard (C++0x)

    Do rate the posts you find useful.

  8. #8
    Join Date
    Feb 2002
    Posts
    3,788
    I think you didn't get what I was trying to say. I KNOW that there are 2 different things, but the number of paramenters DOESN'T change.
    also from the above quoted winuser.h:
    Code:
    WINUSERAPI
    LRESULT
    WINAPI
    SendMessageA(
        HWND hWnd,
        UINT Msg,
        WPARAM wParam,
        LPARAM lParam);
    WINUSERAPI
    LRESULT
    WINAPI
    SendMessageW(
        HWND hWnd,
        UINT Msg,
        WPARAM wParam,
        LPARAM lParam);
    Do you see know what I'm referring to?

  9. #9
    Join Date
    Mar 2003
    Location
    India {Mumbai};
    Posts
    3,871
    Yes buddy, now I got it. I thought you were ignoring the constants definition concept.

    CWnd::SendMessage
    My latest article: Explicating the new C++ standard (C++0x)

    Do rate the posts you find useful.

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

Featured