The problem is exactly what is in the title, my wxWidgets application is breaking down because the conversion from the dialog class to the app class isn't working. Any help?
Error meassage:
error C2440: 'initializing': cannot convert from 'MP *' to 'MPApp *'
error C2664: 'void wxAppBase::SetTopWindow(wxWindow *)': cannot convert argument 1 from 'MPApp *' to 'wxWindow *'
error C2039: 'Show': is not a member of 'MPApp'
MPApp.cpp:
#include "MPApp.h"
#include "MP.h"
IMPLEMENT_APP(MPApp)
bool MPApp::OnInit()
{
MPApp* dialog = new MP((NULL));
SetTopWindow(dialog);
dialog->Show(true);
return true;
}
int MPApp::OnExit()
{
return 0;
}
MPApp.h:
#ifndef __MPApp_h__
#define __MPApp_h__
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include <wx/wx.h>
#else
#include <wx/wxprec.h>
#endif
class MPApp : public wxApp
{
public:
bool OnInit();
int OnExit();
};
#endif
MP.h:
#ifndef __MP_h__
#define __MP_h__
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include <wx/wx.h>
#include <wx/dialog.h>
#else
#include <wx/wxprec.h>
#endif
#include <list>
#include <wx/menu.h>
#include <wx/timer.h>
#include <wx/listctrl.h>
#include <wx/textctrl.h>
#include <wx/stattext.h>
#include <wx/checkbox.h>
#include <wx/mediactrl.h>
#include <wx/slider.h>
#include <wx/button.h>
#include <wx/bmpbuttn.h>
#include <wx/panel.h>
#include <wx/sizer.h>
#include <wx/toplevel.h>
#undef MPSTYLE
#define MPSTYLE wxWANTS_CHARS | wxALWAYS_SHOW_SB | wxCAPTION | wxRESIZE_BORDER | wxSYSTEM_MENU | wxDIALOG_NO_PARENT | wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxCLOSE_BOX
class MP : public wxDialog
{
private:
DECLARE_EVENT_TABLE();
public:
//Constuctor
MP(wxWindow* parent, wxWindowID id = 0, const wxString& title = wxT("Music"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = MPSTYLE);
virtual ~MP();
//Player
void PlayFileNow();
// EVENTS
// Command Events
void AddToQueue(wxCommandEvent& event);
void WxButton1Click(wxCommandEvent& event);
void PlayButtonClick(wxCommandEvent& event);
void NextButtonClick(wxCommandEvent& event);
void PreviousButtonClick(wxCommandEvent& event);
void StopButtonClick(wxCommandEvent& event);
void RandomCheckboxClick(wxCommandEvent& event);
void WxButton2Click(wxCommandEvent& event);
void SavePlaylistClick(wxCommandEvent& event);
void LoadPlaylistClick(wxCommandEvent& event);
void AddButtonClick(wxCommandEvent& event);
void PlaylistsButtonClick(wxCommandEvent& event);
void FindButtonClick(wxCommandEvent& event);
void FindTextEditEnter(wxCommandEvent& event);
void FindNextButtonClick(wxCommandEvent& event);
void FindPrevButtonClick(wxCommandEvent& event);
//Media Events
void WxMediaCtrl1MediaFinished(wxMediaEvent& event);
void WxMediaCtrl1MediaPause(wxMediaEvent& event);
void WxMediaCtrl1MediaPlay(wxMediaEvent& event);
void WxMediaCtrl1MediaStop(wxMediaEvent& event);
void WxMediaCtrl1MediaLoaded(wxMediaEvent& event);
//Key Events
void HotKeyNext(wxKeyEvent& event);
void HotKeyStop(wxKeyEvent& event);
void HotKeyPlay(wxKeyEvent& event);
void HotKeyPrev(wxKeyEvent& event);
//List Events
void WxListCtrl1ColLeftClick(wxListEvent& event);
void WxListCtrl1ColRightClick(wxListEvent& event);
void WxListCtrl1RightClick(wxListEvent& event);
void WxListCtrl1ItemActivated(wxListEvent& event);
void WxListCtrl1KeyDown(wxListEvent& event);
//UI Event
void SavePlaylistUpdateUI0(wxUpdateUIEvent& event);
//Scroll Events
void WxSlider2Scroll(wxScrollEvent& event);
void WxSlider1Scroll(wxScrollEvent& event);
//Timer Event
void WxTimer1Timer(wxTimerEvent& event);
//File Event
void MPDropFiles(wxDropFilesEvent& event);
//Mouse Event
void MPRightUP(wxMouseEvent& event);
private:
//GUI Control
//Menu items
wxMenu* PlaylistMenu;
wxMenu* WxPopupMenu1;
wxMenu* AddMenu;
//Timer item
wxTimer* WxTimer1;
//List item
wxListCtrl* WxListCtrl1;
//Button items
wxButton* FindPrevButton;
wxButton* FindNextButton;
wxButton* AddButton;
wxButton* PlaylistsButton;
wxButton* FindButton;
//Bitmaps
wxBitmapButton* PlayButton;
wxBitmapButton* PreviousButton;
wxBitmapButton* NextButton;
//Text items
wxTextCtrl* FindTextEdit;
wxStaticText* WxStaticText1;
//Slider items
wxSlider* WxSlider2;
wxSlider* WxSlider1;
//Panel items
wxPanel* SearchPanel;
wxPanel* WxPanel1;
wxPanel* WxPanel;
//Check item
wxCheckBox* RandomCheckbox;
//Media item
wxMediaCtrl* WxMediaCtrl1;
//Sizer items
wxFlexGridSizer* WxFlexGridSizer1;
wxBoxSizer* WxBoxSizer1;
private:
//Enum IDs for GUI
enum
{
////GUI Enum Control ID Start
ID_MNU_LOADPLAYLIST_1028 = 1028,
ID_MNU_SAVEPLAYLIST_1029 = 1029,
ID_MNU_PLAY_PAUSE_1019 = 1019,
ID_MNU_STOP_1020 = 1020,
ID_MNU_NEXT_1021 = 1021,
ID_MNU_PREVIOUS_1022 = 1022,
ID_MNU_ADDFOLDER_1023 = 1023,
ID_MNU_SAVEPLAYLIST_1024 = 1024,
ID_MNU_LOADPLAYLIST_1025 = 1025,
ID_MNU_ADDFILES_1026 = 1026,
ID_MNU_ADDFOLDER_1027 = 1027,
ID_WXTIMER1 = 1017,
ID_WXLISTCTRL1 = 1015,
ID_FINDPREVBUTTON = 1034,
ID_FINDNEXTBUTTON = 1033,
ID_FINDEDITTXT = 1044,
ID_WXSTATICTEXT1 = 1032,
ID_SEARCHPANEL = 1031,
ID_FINDBUTTON = 1030,
ID_RANDOMCHECKBOX = 1018,
ID_WXMEDIACTRL1 = 1016,
ID_WXSLIDER2 = 1014,
ID_WXSLIDER1 = 1013,
ID_ADDBUTTON = 1008,
ID_PLAYLISTS = 1007,
ID_NEXTBUTTON = 1006,
ID_STOPBUTTON = 1005,
ID_PLAYBUTTON = 1004,
ID_PREVIOUSBUTTON = 1003,
ID_WXPANEL2 = 1002,
ID_WXPANEL1 = 1011,
////GUI Enum Control ID End
ID_HOT_PLAY,
ID_HOT_STOP,
ID_HOT_NEXT,
ID_HOT_PREV,
ID_DUMMY_VALUE_ //don't remove this value unless you have other enum values
};
private:
void OnClose(wxCloseEvent& event);
void CreateGUIControls();
protected:
// No description
void AddFilesFromFolder(wxString FileName);
//FileList Dirs, Files;
//wxTreeItemId root;
bool isPlaying;
long selItem;
// No description
void PlayThisFile(long id);
// No description
void PlayFromQueue();
std::list<wxString> lastPlayed, nextPlay;
// No description
void PlayNextFile();
void DeselectAllFiles();
};
#endif
I couldn't include MP.cpp due to the length of the file, but it compiles fine and I have already debugged the issues.
Aucun commentaire:
Enregistrer un commentaire