Hé ben, j'utilise Dev cpp 4.9.9.2 avec Wxwidgets 2.6.2.
Mon code (avec votre code intégré) :
mainframe.cpp
#if defined(__GNUG__) && !defined(__APPLE__)
#pragma implementation "mainframe.h"
#endif
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
// for all others, include the necessary headers (this file is usually all you
// need because it includes almost all "standard" wxWindows headers)
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include "wx/app.h"
#include "wx/dirctrl.h"
#include "mainframe.h"
// ----------------------------------------------------------------------------
// resources
// ----------------------------------------------------------------------------
// the application icon (under Windows and OS/2 it is in resources)
#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXMGL__) || defined(__WXX11__)
#include "toolchar.xpm"
#endif
#define ID_DIRCTRL 10001
IMPLEMENT_CLASS( wxMainFrame, wxFrame )
BEGIN_EVENT_TABLE( wxMainFrame, wxFrame )
END_EVENT_TABLE()
// ----------------------------------------------------------------------------
// private classes
// ----------------------------------------------------------------------------
// Define a new application type, each program should derive a class from wxApp
class MyApp : public wxApp
{
public:
// override base class virtuals
// ----------------------------
// this one is called on application startup and is a good place for the app
// initialization (doing it here and not in the ctor allows to have an error
// return: if OnInit() returns false, the application terminates)
virtual bool OnInit();
};
// Define a new frame type: this is going to be our main frame
class MyFrame : public wxFrame
{
public:
// ctor(s)
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size,
long style = wxDEFAULT_FRAME_STYLE);
// event handlers (these functions should _not_ be virtual)
void OnNouveau(wxCommandEvent& event);
void OnOuvrir(wxCommandEvent& event);
void OnEnregistrer(wxCommandEvent& event);
void OnQuitter(wxCommandEvent& event);
void OnProprietes(wxCommandEvent& event);
void OnCouper(wxCommandEvent& event);
void OnCopier(wxCommandEvent& event);
void OnColler(wxCommandEvent& event);
void OnSupprimer(wxCommandEvent& event);
void OnRenomer(wxCommandEvent& event);
void OnRechercher(wxCommandEvent& event);
void OnSelectout(wxCommandEvent& event);
void OnSelectimage(wxCommandEvent& event);
void OnEffacerselec(wxCommandEvent& event);
void OnApercu(wxCommandEvent& event);
void OnBaroutils(wxCommandEvent& event);
void OnModaffi(wxCommandEvent& event);
void OnClasser(wxCommandEvent& event);
void OnPivoter(wxCommandEvent& event);
void OnRedim(wxCommandEvent& event);
void OnPapierpeint(wxCommandEvent& event);
void OnAide(wxCommandEvent& event);
void OnInfo(wxCommandEvent& event);
private:
// any class wishing to process wxWindows events must use this macro
DECLARE_EVENT_TABLE()
};
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
// IDs for the controls and the menu commands
enum
{
// menu items
DSW_Quitter = 1,
DSW_Nouveau,
DSW_Ouvrir,
DSW_Enregistrer,
DSW_Proprietes,
DSW_Couper,
DSW_Copier,
DSW_Coller,
DSW_Supprimer,
DSW_Renomer,
DSW_Rechercher,
DSW_Selectout,
DSW_Selectimage,
DSW_Effacerselec,
DSW_Apercu,
DSW_Baroutils,
DSW_Modaffi,
DSW_Classer,
DSW_Pivoter,
DSW_Redim,
DSW_Papierpeint,
DSW_Aide,
Dir,
// it is important for the id corresponding to the "About" command to have
// this standard value as otherwise it won't be handled properly under Mac
// (where it is special and put into the "Apple" menu)
DSW_Info = wxID_ABOUT
};
// ----------------------------------------------------------------------------
// event tables and other macros for wxWindows
// ----------------------------------------------------------------------------
// the event tables connect the wxWindows events with the functions (event
// handlers) which process them. It can be also done at run-time, but for the
// simple menu events like this the static method is much simpler.
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(DSW_Quitter, MyFrame::OnQuitter)
EVT_MENU(DSW_Nouveau, MyFrame::OnNouveau)
EVT_MENU(DSW_Ouvrir, MyFrame::OnOuvrir)
EVT_MENU(DSW_Enregistrer, MyFrame::OnEnregistrer)
EVT_MENU(DSW_Proprietes, MyFrame::OnProprietes)
EVT_MENU(DSW_Couper, MyFrame::OnCouper)
EVT_MENU(DSW_Copier, MyFrame::OnCopier)
EVT_MENU(DSW_Coller, MyFrame::OnColler)
EVT_MENU(DSW_Supprimer, MyFrame::OnSupprimer)
EVT_MENU(DSW_Renomer, MyFrame::OnRenomer)
EVT_MENU(DSW_Rechercher, MyFrame::OnRechercher)
EVT_MENU(DSW_Selectout, MyFrame::OnSelectout)
EVT_MENU(DSW_Selectimage, MyFrame::OnSelectimage)
EVT_MENU(DSW_Effacerselec, MyFrame::OnEffacerselec)
EVT_MENU(DSW_Apercu, MyFrame::OnApercu)
EVT_MENU(DSW_Baroutils, MyFrame::OnBaroutils)
EVT_MENU(DSW_Modaffi, MyFrame::OnModaffi)
EVT_MENU(DSW_Classer, MyFrame::OnClasser)
EVT_MENU(DSW_Pivoter, MyFrame::OnPivoter)
EVT_MENU(DSW_Redim, MyFrame::OnRedim)
EVT_MENU(DSW_Papierpeint, MyFrame::OnPapierpeint)
EVT_MENU(DSW_Aide, MyFrame::OnAide)
EVT_MENU(DSW_Info, MyFrame::OnInfo)
END_EVENT_TABLE()
// Create a new application object: this macro will allow wxWindows to create
// the application object during program execution (it's better than using a
// static object for many reasons) and also declares the accessor function
// wxGetApp() which will return the reference of the right type (i.e. MyApp and
// not wxApp)
IMPLEMENT_APP(MyApp)
// ============================================================================
// implementation
// ============================================================================
// ----------------------------------------------------------------------------
// the application class
// ----------------------------------------------------------------------------
// 'Main program' equivalent: the program execution "starts" here
bool MyApp::OnInit()
{
// create the main application window
MyFrame *frame = new MyFrame(_T("AfroView"),
wxPoint(100, 50), wxSize(600, 600), wxDEFAULT_FRAME_STYLE | wxTAB_TRAVERSAL);
// and show it (the frames, unlike simple controls, are not shown when
// created initially)
frame->Show(TRUE);
// success: wxApp::OnRun() will be called which will enter the main message
// loop and the application will run. If we returned FALSE here, the
// application would exit immediately.
return TRUE;
}
// ----------------------------------------------------------------------------
// main frame
// ----------------------------------------------------------------------------
// frame constructor
wxMainFrame::wxMainFrame(wxWindow* parent, wxWindowID id,
const wxString& caption, const wxPoint& pos,
const wxSize& size, long style)
{
Create(parent, id, caption, pos, size, style);
}
bool wxMainFrame::Create(wxWindow* parent, wxWindowID id,
const wxString& caption, const wxPoint& pos,
const wxSize& size, long style)
{
GenDirCtrl = NULL;
wxFrame::Create( parent, id, caption, pos, size, style );
CreateControls();
return TRUE;
}
void wxMainFrame::CreateControls()
{
GenDirCtrl = new wxGenericDirCtrl(this, ID_DIRCTRL, wxEmptyString,
wxDefaultPosition, wxDefaultSize,
/*wxDIRCTRL_SHOW_FILTERS*/0,
_T("All files (*.*)|*.*|Text Files (*.txt)|*.txt"),
0);
// Attention l'utilisation du style wxDIRCTRL_SHOW_FILTERS pose
// problème l'affichage ne se faisant pas correctement un message
// sur comp.soft-sys.wxwindows évoque le problème
}
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, long style)
: wxFrame(NULL, -1, title, pos, size, style)
{
// set the frame icon
SetIcon(wxICON(toolchar));
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
#if wxUSE_MENUS
// create a menu bar
wxMenu *menuFichier = new wxMenu;
menuFichier->Append(DSW_Nouveau, _T("&Nouveau\tCtrl-N"), _T("Créer un nouveau fichier"));
menuFichier->Append(DSW_Ouvrir, _T("&Ouvrir\tCtrl-O"), _T("Ouvrir un fichier"));
menuFichier->Append(DSW_Enregistrer, _T("&Enregistrer sous\tCtrl-S"), _T("Enregistrer le fichier en cours"));
menuFichier->Append(DSW_Proprietes, _T("&Proriètés"), _T("Propriètés du fichier"));
menuFichier->Append(DSW_Quitter, _T("&Quitter\tAlt-Q"), _T("Quitter ce programme"));
wxMenu *menuEditer = new wxMenu;
menuEditer->Append(DSW_Couper, _T("&Couper\tCtrl-X"));
menuEditer->Append(DSW_Copier, _T("&Copier\tCtrl-C"));
menuEditer->Append(DSW_Coller, _T("&Coller\tCtrl-V"));
menuEditer->Append(DSW_Supprimer, _T("Supprimer"));
menuEditer->Append(DSW_Renomer, _T("Renomer"));
menuEditer->Append(DSW_Rechercher, _T("Rechercher"));
menuEditer->Append(DSW_Selectout, _T("Selectionner tout"));
menuEditer->Append(DSW_Selectimage, _T("Selectionner les images"));
menuEditer->Append(DSW_Effacerselec, _T("Effacer la sélectoin"));
wxMenu *menuAffichage = new wxMenu;
menuAffichage->Append(DSW_Apercu, _T("Aperçu"));
menuAffichage->Append(DSW_Baroutils, _T("Barre d'outils"));
menuAffichage->Append(DSW_Modaffi, _T("Mode d'affichage"));
wxMenu *menuOutils = new wxMenu;
menuOutils->Append(DSW_Classer, _T("Classer"));
menuOutils->Append(DSW_Pivoter, _T("Faire pivoter"));
menuOutils->Append(DSW_Redim, _T("Redimensionner"));
menuOutils->Append(DSW_Renomer, _T("Renomer"));
menuOutils->Append(DSW_Papierpeint, _T("Utiliser comme papier peint"));
// the "About" item should be in the help menu
wxMenu *menuAide = new wxMenu;
menuAide->Append(DSW_Aide, _T("Aide"));
menuAide->Append(DSW_Info, _T("&A propos de...\tF1"));
// now append the freshly created menu to the menu bar...
wxMenuBar *menuBar = new wxMenuBar();
menuBar->Append(menuFichier, _T("&Fichier"));
menuBar->Append(menuEditer, _T("&Editer"));
menuBar->Append(menuAffichage, _T("&Affichage"));
menuBar->Append(menuOutils, _T("&Outils"));
menuBar->Append(menuAide, _T("&Aide"));
// ... and attach this menu bar to the frame
SetMenuBar(menuBar);
#endif // wxUSE_MENUS
#if wxUSE_STATUSBAR
// create a status bar just for fun (by default with 1 pane only)
CreateStatusBar(2);
SetStatusText(_T("AfroView : Organiser et visualiser vos images en toute simplicité"));
#endif // wxUSE_STATUSBAR
}
// event handlers
void MyFrame::OnNouveau(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
void MyFrame::OnOuvrir(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
void MyFrame::OnEnregistrer(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
void MyFrame::OnProprietes(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
void MyFrame::OnQuitter(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
void MyFrame::OnCouper(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
void MyFrame::OnCopier(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
void MyFrame::OnColler(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
void MyFrame::OnSupprimer(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
void MyFrame::OnRenomer(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
void MyFrame::OnRechercher(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
void MyFrame::OnSelectout(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
void MyFrame::OnSelectimage(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
void MyFrame::OnEffacerselec(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
void MyFrame::OnApercu(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
void MyFrame::OnBaroutils(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
void MyFrame::OnModaffi(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
void MyFrame::OnClasser(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
void MyFrame::OnPivoter(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
void MyFrame::OnRedim(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
void MyFrame::OnPapierpeint(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
void MyFrame::OnAide(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
void MyFrame::OnInfo(wxCommandEvent& WXUNUSED(event))
{
wxString msg;
msg.Printf( _T("AfroView.\n")
_T("By AfroDurf, version 1.0"));
wxMessageBox(msg, _T("A propos d'AfroView..."), wxOK | wxICON_INFORMATION, this);
}
mainframe.h
#ifndef _MAINFRAME_H_
#define _MAINFRAME_H_
#if defined(__GNUG__) && !defined(__APPLE__)
#pragma interface "mainframe.cpp"
#endif
class wxGenericDirCtrl;
class wxMainFrame: public wxFrame
{
public:
wxMainFrame();
wxMainFrame(wxWindow* parent, wxWindowID id = -1,
const wxString& caption = _("Test wxGenericDirCtrl"),
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE);
bool Create(wxWindow* parent, wxWindowID id = -1,
const wxString& caption = _("Test wxGenericDirCtrl"),
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE);
protected:
void CreateControls();
private:
wxGenericDirCtrl* GenDirCtrl;
DECLARE_CLASS(wxMainFrame)
DECLARE_EVENT_TABLE()
};
#endif // _MAINFRAME_H_
AV.rc
// RESOURCES OF THIS PROJECT
// DO NOT REMOVE THIS LINE (WXWIDGETS RESOURCE)
#include <wx/msw/wx.rc>
