Visual Studio Developer Center > Visual C++ Forums > Visual C++ Language > Some Error when compiling a VC6 code with VS2008... Please Help

Answered Some Error when compiling a VC6 code with VS2008... Please Help

  • Thursday, February 18, 2010 8:16 PM
     
     

    Playsound.cpp
    BEGIN_MESSAGE_MAP(PlaySound1, CWinThread)
            ON_THREAD_MESSAGE(WM_PLAYSOUND_STARTPLAYING, OnStartPlaying)

     END_MESSAGE_MAP()

    Error


    playsound.cpp(38) : error C2440: 'static_cast' : cannot convert from 'LRESULT (__thiscall PlaySound1::* )(WPARAM,LPARAM)' to 'void (__thiscall CWinThread::* )(WPARAM,LPARAM)'

    1>        None of the functions with this name in scope match the target type

     

    I tried to put the whole source and header files .. but the page can't disply them all

    can anyone help :)

    • Edited by Just Click Thursday, February 18, 2010 8:22 PM
    •  

Answers

  • Friday, February 19, 2010 6:04 PM
     
     Answered

    For the OnStartPlaying function change LRESULT to void

    At the end of the function remove the "return" statement.

     

  • Friday, February 19, 2010 6:06 PM
     
     Answered
    Most people are not going to download a whole project.

    In your PlaySound1 class definition in playsound.h, you must a have a method that is declared

    LRESULT OnStartPlaying(WPARAM wParam, LPARAM lParam);

    or maybe

    afx_msg LRESULT OnStartPlaying(WPARAM wParam, LPARAM lParam);

    Change LRESULT to void.

    Likewise, in playsound.cpp you must have the implementation

    LRESULT PlaySound1::OnStartPlaying(WPARAM wParam, LPARAM lParam)
    {
       // code is here
    }

    Again, replace LRESULT by void. And change the return statements in the function to eliminate the return value.

    This was actually a breaking change in VC7 and later compared to VC6.

    David Wilkinson | Visual C++ MVP

All Replies

  • Thursday, February 18, 2010 8:22 PM
     
     Proposed Answer
    Your message handler function signature is wrong.  Its return type should be void.

    VC6 did not detect errors in message handler signatures.
    • Proposed As Answer by jinzai Monday, February 22, 2010 8:28 PM
    •  
  • Friday, February 19, 2010 2:58 PM
     
     
    First of all ... Thanks Mr.Scott for the very very fast answer :)


    This is the link to the complete project. If u please, download and compile it. There are a few errors that I have solved, but I couldn’t solve the error that I showed before cause I have a little experience in programming…. Can anyone exactly show me how to fix this problem ??


    http://www.codeproject.com/KB/IP/videonet/VideoNet_src.zip


    Thanks All
  • Friday, February 19, 2010 6:04 PM
     
     Answered

    For the OnStartPlaying function change LRESULT to void

    At the end of the function remove the "return" statement.

     

  • Friday, February 19, 2010 6:06 PM
     
     Answered
    Most people are not going to download a whole project.

    In your PlaySound1 class definition in playsound.h, you must a have a method that is declared

    LRESULT OnStartPlaying(WPARAM wParam, LPARAM lParam);

    or maybe

    afx_msg LRESULT OnStartPlaying(WPARAM wParam, LPARAM lParam);

    Change LRESULT to void.

    Likewise, in playsound.cpp you must have the implementation

    LRESULT PlaySound1::OnStartPlaying(WPARAM wParam, LPARAM lParam)
    {
       // code is here
    }

    Again, replace LRESULT by void. And change the return statements in the function to eliminate the return value.

    This was actually a breaking change in VC7 and later compared to VC6.

    David Wilkinson | Visual C++ MVP
  • Monday, February 22, 2010 5:06 PM
     
     
    thanks all,

    all things work perfectly

    thanks again :)
  • Monday, February 22, 2010 5:08 PM
     
     
    Would you mind selecting Scott's and/or Dave's posts as your answer, then? Thanks.