Code: Select all
#include "testdrawMain.h"
#include <wx/msgdlg.h>
#include <wx/filedlg.h>
#include <wx/wx.h>
#include "openfile.h"
#include <wx/msgdlg.h>
#include <wx/msw/dialog.h>
#include <stdio.h>
#include "wx/listctrl.h"
//(*InternalHeaders(testdrawFrame)
#include <wx/intl.h>
#include <wx/string.h>
//*)
//helper functions
enum wxbuildinfoformat {
short_f, long_f };
wxString wxbuildinfo(wxbuildinfoformat format)
{
wxString wxbuild(wxVERSION_STRING);
if (format == long_f )
{
#if defined(__WXMSW__)
wxbuild << _T("-Windows");
#elif defined(__UNIX__)
wxbuild << _T("-Linux");
#endif
#if wxUSE_UNICODE
wxbuild << _T("-Unicode build");
#else
wxbuild << _T("-ANSI build");
#endif // wxUSE_UNICODE
}
return wxbuild;
}
//(*IdInit(testdrawFrame)
const long testdrawFrame::ID_BUTTON1 = wxNewId();
const long testdrawFrame::ID_BUTTON2 = wxNewId();
const long testdrawFrame::ID_BUTTON3 = wxNewId();
const long testdrawFrame::ID_PANEL1 = wxNewId();
const long testdrawFrame::ID_LISTCTRL1 = wxNewId();
const long testdrawFrame::idMenuQuit = wxNewId();
const long testdrawFrame::idMenuAbout = wxNewId();
const long testdrawFrame::ID_STATUSBAR1 = wxNewId();
//*)
BEGIN_EVENT_TABLE(testdrawFrame,wxFrame)
//(*EventTable(testdrawFrame)
//*)
END_EVENT_TABLE()
testdrawFrame::testdrawFrame(wxWindow* parent,wxWindowID id)
{
//(*Initialize(testdrawFrame)
wxMenuItem* MenuItem2;
wxMenuItem* MenuItem1;
wxMenu* Menu1;
wxMenuBar* MenuBar1;
wxMenu* Menu2;
Create(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("wxID_ANY"));
SetClientSize(wxSize(772,385));
openfile = new wxButton(this, ID_BUTTON1, _("openfile"), wxPoint(16,16), wxSize(64,23), 0, wxDefaultValidator, _T("ID_BUTTON1"));
Button2 = new wxButton(this, ID_BUTTON2, _("Label"), wxPoint(208,16), wxSize(64,24), 0, wxDefaultValidator, _T("ID_BUTTON2"));
Button3 = new wxButton(this, ID_BUTTON3, _("Label"), wxPoint(112,16), wxSize(64,24), 0, wxDefaultValidator, _T("ID_BUTTON3"));
Panel1 = new wxPanel(this, ID_PANEL1, wxPoint(144,56), wxSize(592,256), wxTAB_TRAVERSAL, _T("ID_PANEL1"));
ListCtrl1 = new wxListCtrl(this, ID_LISTCTRL1, wxPoint(8,56), wxSize(120,256), wxLC_LIST, wxDefaultValidator, _T("ID_LISTCTRL1"));
MenuBar1 = new wxMenuBar();
Menu1 = new wxMenu();
MenuItem1 = new wxMenuItem(Menu1, idMenuQuit, _("Quit\tAlt-F4"), _("Quit the application"), wxITEM_NORMAL);
Menu1->Append(MenuItem1);
MenuBar1->Append(Menu1, _("&File"));
Menu2 = new wxMenu();
MenuItem2 = new wxMenuItem(Menu2, idMenuAbout, _("About\tF1"), _("Show info about this application"), wxITEM_NORMAL);
Menu2->Append(MenuItem2);
MenuBar1->Append(Menu2, _("Help"));
SetMenuBar(MenuBar1);
StatusBar1 = new wxStatusBar(this, ID_STATUSBAR1, 0, _T("ID_STATUSBAR1"));
int __wxStatusBarWidths_1[1] = { -1 };
int __wxStatusBarStyles_1[1] = { wxSB_NORMAL };
StatusBar1->SetFieldsCount(1,__wxStatusBarWidths_1);
StatusBar1->SetStatusStyles(1,__wxStatusBarStyles_1);
SetStatusBar(StatusBar1);
FileDialog1 = new wxFileDialog(this, _("Select file"), wxEmptyString, wxEmptyString, _("WAV | *.wav"), wxFD_OPEN, wxDefaultPosition, wxDefaultSize, _T("wxFileDialog"));
Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&testdrawFrame::OnButton1Click);
Connect(idMenuQuit,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&testdrawFrame::OnQuit);
Connect(idMenuAbout,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&testdrawFrame::OnAbout);
//*)
}
testdrawFrame::~testdrawFrame()
{
//(*Destroy(testdrawFrame)
//*)
}
void testdrawFrame::OnQuit(wxCommandEvent& event)
{
Close();
}
void testdrawFrame::OnAbout(wxCommandEvent& event)
{
wxString msg = wxbuildinfo(long_f);
wxMessageBox(msg, _("Welcome to..."));
}
void testdrawFrame::OnButton1Click(wxCommandEvent& event)
{
wxFileDialog* FileDialog1 =new wxFileDialog (this);
if(FileDialog1->ShowModal() == wxID_OK)
{
wxString strname = FileDialog1->GetTitle();
wxString fileName = FileDialog1->GetPath();
wxListItem item;
item.m_itemId = 0;
item.m_col = 0;
item.m_text = fileName;
ListCtrl1->InsertItem(item);
}
}
As you advice, Learning to watching the tutorial. but It takes longer to learn how to use.
sorry.....i'm really beginner.....Earnestly ask for your help.