begin process at 2012 02 11 11:46:18
  Trouver un code source :
 
dans
 
Accueil > Forum > 

Archive C/C++

 > 

Archives

 > 

Fichier / Disque

 > 

Wxgenericdirctrl


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

Wxgenericdirctrl

mardi 25 octobre 2005 à 17:17:54 | Wxgenericdirctrl

AfroDurf

Bonjour,

voilà je cherche à faire une zone dans ma fenêtre principale pour l'utiliser comme explorer de fichier. J'ai vu sur le forum qu'un exemple était dispo sur le site de Fredl (XPm convert). C'est effectivement ce genre de chose que je recherche mais je ne comprends pas le fonctionnement de Wxgenericdirctrl  car je tente de créer une listbox d'y appliquer Wxgenericdirctrl  mais sans succès. dans l'exemple de Xmp il passe par une frame dans un header. Je ne comprends pas pourquoi l'application direct decette fonction dans une liste box n'est pas possible?

Vous avez une explication ou une piste?

Merci d'avance

Developpement votre !!!
mardi 25 octobre 2005 à 17:32:54 | Re : Wxgenericdirctrl

fredcl

Bonjour,

wxGenericDirCtrl n'est pas une fonction mais un classe.
Pour être précis c'est un controle composé de deux autres controles un wxTreeCtrl  et en option un wxChoice.

Il faut donc utiliser le wxGenericDirCtrl à la place de votre listbox.

Cordialement

Fred Cailleau-Lepetit ( [ Lien ])

jeudi 27 octobre 2005 à 11:03:28 | Re : Wxgenericdirctrl

AfroDurf

Bonjour,

cela fait quatre jour et je n'arrive a rien avec cette classe wxgenericdirctrl...

Je cherche un exemple de code simple, une fenêtre et le control Wxgenericdirctrl qui affiche l'arbo du pc histoire de comprendre le fonctionnement. Mais je ne trouve ça nul part je ne comprend pas en fait!!!

jeudi 27 octobre 2005 à 11:30:29 | Re : Wxgenericdirctrl

AfroDurf

Si ça peut aider mon code :
============================================================================
// declarations
// ============================================================================

// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------

// 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/dirctrl.h"
#include "wx/dir.h"
#include "wx/filename.h"
// ----------------------------------------------------------------------------
// resources
// ----------------------------------------------------------------------------

#define ID_ARBO             10001


// the application icon (under Windows and OS/2 it is in resources)
#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXMGL__) || defined(__WXX11__)
    #include "mondrian.xpm"
#endif


// ----------------------------------------------------------------------------
// 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()
         
};


class DirFrame: public wxGenericDirCtrl
{
   DECLARE_EVENT_TABLE()

   public:

      DirFrame(wxWindow* parent, const wxPoint& pos = wxDefaultPosition,
               const wxSize& size = wxSize(400, 300));


      void DirDir();
     
   private:
      wxGenericDirCtrl* Dir;
};

// ----------------------------------------------------------------------------
// 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,
    dcDirectory,
   
   
    // 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

DirFrame::DirFrame(wxWindow* parent, const wxPoint& pos, const wxSize& size)
{

   Dir = NULL;

}

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(mondrian));
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);
}


void DirFrame::DirDir()
{

Dir = new wxGenericDirCtrl(ID_ARBO, wxEmptyString,
                                     wxDefaultPosition, wxDefaultSize,
                                     wxDIRCTRL_3D_INTERNAL|wxDIRCTRL_EDIT_LABELS|wxSUNKEN_BORDER,
                                     _("All files (*.*)|*.*"), 0);


}

jeudi 27 octobre 2005 à 12:41:37 | Re : Wxgenericdirctrl

fredcl

Bonjour,

Voici un code pour créer une fenêtre simple (wxFrame) contenant un wxGenericDirCtrl:

fichier 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_
---------

fichier 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

#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif

#include "wx/dirctrl.h"
#include "mainframe.h"

#define ID_DIRCTRL 10001

IMPLEMENT_CLASS( wxMainFrame, wxFrame )

BEGIN_EVENT_TABLE( wxMainFrame, wxFrame )
END_EVENT_TABLE()

wxMainFrame::wxMainFrame(){}

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
}
---------
J'espère que ce code répond à votre question

Cordialement

Fred Cailleau-Lepetit ( [ Lien ])

jeudi 27 octobre 2005 à 14:53:50 | Re : Wxgenericdirctrl

AfroDurf

Merci beaucoup pour ce code Fred qui m'éclaire.

Cependant,  j'ai fait le test rapide avec ce code (je n'ai plus d'erreur lors de la compilation, se qui est déja énorme) mais dans ma fenêtre je n'ai rien en fait !! Je l'ai inséré dans mon code etle résultat est toujours ma fenêtre, mes menus et c'est tout, pas de fenêtre avec mon arborescence ????

Est-ce que c'est parce que je dois créer une Wxtreectrl?

Merci d'avance.

Developpement Vôtre !!!
jeudi 27 octobre 2005 à 15:22:00 | Re : Wxgenericdirctrl

fredcl

La compilation de ce code (en ajoutant les fichiers pour la classe dérivée de wxApp bien sur) et uniquement de ce code fonctionne t'elle correctement?
Si non, quel version de wxWidgets utilisez vous?
Non vous ne devez rien créer de plus, pour l'instant.

Cordialement

Fred Cailleau-Lepetit ( [ Lien ])

jeudi 27 octobre 2005 à 15:27:04 | Re : Wxgenericdirctrl

fredcl

Voila précisément ce que j'obtiens avec mon code.



Cordialement

Fred Cailleau-Lepetit ( [ Lien ])

jeudi 27 octobre 2005 à 15:55:34 | Re : Wxgenericdirctrl

AfroDurf

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>


jeudi 27 octobre 2005 à 15:56:06 | Re : Wxgenericdirctrl

AfroDurf

J'obtiens ceci

1 2

Cette discussion est classée dans : exemple, comprends, wxgenericdirctrl


Répondre à ce message

Sujets en rapport avec ce message

Problème de syntaxe [ par DoudouBidou ] je dois récupérer un tableau de Long et j'ai un exemple pour le faire mais je ne comprends pas la syntaxe qqn peut m'aider ? Exemple : arrayDa Intercepter conversations MSN [ par ncoder ] Salut à tous,Est-ce que qqun pourrait m'expliquer comment faire pour pouvoir intercepter les conversations d'MSN Messenger (avant qu'elles s'affichent Exemple de toolbar avec Edit ? [ par Zootella ] Hello, Est-ce que quelqu'un aurait un petit exemple de toolbar avec juste un edit dedans ? sans MFC. merci ! 3D et Animations : Débat [ par mondrone ] Voila ma question. Après, à vous de juger de sa pertinence (voir de sa redondance). Dans tous les jeux vidéos que je connais. On peut voir dans les fi Question toute bête d'affichage d'éléments ^^ [ par by_rabbit_08 ] Bonjour!! J'ai une question surement fort simple pour beaucoup d'entre vous: Lorsque j'ai une simple fenêtre avec par exemple un bouton, une image, e A propos des chaînes de caractères [ par OzStrycker ] Bonjour, Voilà j'ai lu dans beaucoup de tutoriels que les chaînes de caractères sont des tableaux de caractères terminés par un 0. Bon jusque là OK, HANDLE de fichiers [ par vecchio56 ] Salut J'ai un programme qui travaille sur des fichiers, et l'utilisateur peut enregistrer le fichier quand il le veut. La question que je me pose est Fonction En Paramètre [ par Joky ] Hep Hello les gens :) J'ai une question qui me tarrode l'esprit voyez vous Exemple explicite LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM ); effacement automatique [ par dann3 ] Je cherche à lancer au démarrage de Windows un fichier texte dans notepad(par exemple) jusque là je sais faire... mais comment faire disparaitre autom Je ne comprends plus rien aux lumieres [ par Ensias ] Salut tous le monde, je viens de debuter Opengl et je gallere avec les lumieres.J'ai cree une petite scene qui comporte 2 cubes, l'un des deux est fix


Nos sponsors


Sondage...

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 2,449 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales