No matching function for call to m_mediaCtrl->Create(...)

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
RuudH
In need of some credit
In need of some credit
Posts: 9
Joined: Thu Jun 04, 2020 6:35 am

No matching function for call to m_mediaCtrl->Create(...)

Post by RuudH » Mon Jun 08, 2020 7:17 am

I like to add a player to an existing project after successfully creating a dedicated player in Code::Blocks (C++ with wxWidgets).

I have added a class (PlayerWX.h + PlayerWX.cpp) to the existing project (File->New->Class...) with the default settings.
The top-end in the .cpp is:

Code: Select all

    #include "PlayerWX.h"
       
    // Lib Headers
    #include <iostream>
    
    // wxWidgets
    #include <wx/msgdlg.h>
    #include <wx/mediactrl.h>
    #include <wx/string.h>
    
    enum
    {
        // Menu event IDs
        ....
        wxID_MEDIACTRL,
        ....
    };
I call SetupMedia() in the Constructor
the Code in SetupMedia() is:

Code: Select all

    m_mediaCtrl = new wxMediaCtrl();
    
    bool bOK = m_mediaCtrl->Create(this, wxID_MEDIACTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxMEDIABACKEND_WMP10);
    this->Connect(wxEVT_MEDIA_PLAY, (wxObjectEventFunction) (wxEventFunction)(wxMediaEventFunction) &wxPlayer::OnMediaPlay);
    etc...
I have below error in SetupMedia() when building

Code: Select all

    error: no matching function for call to
    'wxMediaCtrl::Create(PlayerWX*, <unnamed enum>, const wxChar*&, const wxPoint&, const wxSize&, int, const wchar_t [20])'
I do not understand why this code is working in a Code::Blocks project with the code in a dedicated player project,
and receive above error when I add a class to my existing Gui project using the exact same code.

Please help
RuudH

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2469
Joined: Sun Jan 03, 2010 5:45 pm

Re: No matching function for call to m_mediaCtrl->Create(...)

Post by PB » Mon Jun 08, 2020 10:24 am

Is PlayerWX derived from wxWindow?

What is the difference between wxPlayer (its method is used in the Connect() call as an event handler) and PlayerWX?

BTW, using those three casts in Connect() is terrible. Why not use Bind() instead which is not only more readable but also less error-prone.

Post Reply