DevC++ Frame et la methode Hide

cs_imedghar Messages postés 1 Date d'inscription dimanche 8 juin 2003 Statut Membre Dernière intervention 9 juillet 2006 - 11 déc. 2004 à 16:29
assekkal Messages postés 3 Date d'inscription dimanche 8 juin 2003 Statut Membre Dernière intervention 14 août 2006 - 20 déc. 2004 à 13:16
Slt tlm,
je suis entrain de programmer des GUI avec wxwundows et dev C++.
j´ai le probleme suivant:
j´ai deux frames (HauptFrame et ActionFrame), pour le moment je veux seulement quand j´ouvre la Fenetre Action, je veux que la fenetre principale se cache (pas la fermer totalement), et quand je ferme la fenetre Action, je veux avoir ma fenetre Haupt d´avant.
je crois que je dois utiliser la methode Hide(), j´ai essayer , mais je n´yarrive pas???
qqn peux m´aider ?? Merci d´avance.

voila le code:
//frame.h
#ifndef frameH
#define frameH
// for action frame
#define ID_OK 1
#define ID_CLEAR 2
#define ID_APP_QUIT 3
// for haupt frame
#define ID_ACTION 5

//------------------------------------------------------------------------------
class MyApp : public wxApp{
public:
virtual bool OnInit();
};
//------------------------------------------------------------------------------
/*
* --- The main frame -----
*/
class HauptFrame : public wxFrame{
public:
HauptFrame(const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style = wxDEFAULT_FRAME_STYLE);


void OnAction(wxCommandEvent& event);
void OnQuit(wxCommandEvent& event);



private:

wxButton *ActionBouton;
wxButton *CloseBouton;
DECLARE_EVENT_TABLE()
};

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/*
* --- The frame of the action -----
*/
class ActionFrame : public wxFrame{
public:
ActionFrame(const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style = wxDEFAULT_FRAME_STYLE);

void OnQuit(wxCommandEvent& event);
void OnClear(wxCommandEvent& event);
void OnOK(wxCommandEvent& event);

private:
wxButton *OKBouton;
wxButton *ClearBouton;
wxButton *CancelBouton;
wxTextCtrl *theText; // for the textfield
wxStaticText *label;
DECLARE_EVENT_TABLE()
};
#endif //framesH

//main.cpp

#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
//------------------------------------------------------------------------------
#include "frame.h"
#include

BEGIN_EVENT_TABLE(HauptFrame, wxFrame)
EVT_BUTTON(ID_ACTION, HauptFrame::OnAction)
EVT_BUTTON(ID_APP_QUIT, HauptFrame::OnQuit)
END_EVENT_TABLE()

BEGIN_EVENT_TABLE(ActionFrame, wxFrame)
EVT_BUTTON(ID_OK, ActionFrame::OnOK)
EVT_BUTTON(ID_CLEAR, ActionFrame::OnClear)
EVT_BUTTON(ID_APP_QUIT, ActionFrame::OnQuit)
END_EVENT_TABLE()

IMPLEMENT_APP(MyApp)

//------------------------------------------------------------------------------
bool MyApp::OnInit(){
HauptFrame *hframe = new HauptFrame("OpMaker2",
wxPoint(150, 150),
wxSize(580, 360));
hframe->Show(true);
return true;
}
//------------------------------------------------------------------------------
//--------------------- Implementation of the main frame ----------------------
//------------------------------------------------------------------------------
HauptFrame::HauptFrame(const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style) : wxFrame(NULL, -1, title, pos, size, style)
{
SetIcon(wxICON(monicone));
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));

ActionBouton = new wxButton(this,ID_ACTION,"Action ",
wxPoint(200,40), wxDefaultSize);

CloseBouton = new wxButton(this,ID_APP_QUIT,"Close",
wxPoint(140,160), wxDefaultSize);

}
//------------------------------------------------------------------------------
void HauptFrame::OnAction(wxCommandEvent& WXUNUSED(event)){
ActionFrame *frame = new ActionFrame("Action sequence",
wxPoint(190, 190),
wxSize(580, 360));
frame->Show(true);

}
//------------------------------------------------------------------------------
void HauptFrame::OnQuit(wxCommandEvent& WXUNUSED(event)){
Close(true);

}

//------------------------------------------------------------------------------
//--------------------- Inplementation of the action frame ------------
//------------------------------------------------------------------------------

ActionFrame::ActionFrame(const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style) : wxFrame(NULL, -1, title, pos, size, style)
{
SetIcon(wxICON(monicone));
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
OKBouton = new wxButton(this,ID_OK,"OK",
wxPoint(400,60), wxDefaultSize);
ClearBouton = new wxButton(this,ID_CLEAR,"Clear",
wxPoint(400,100), wxDefaultSize);
CancelBouton = new wxButton(this,ID_APP_QUIT,"Cancel",
wxPoint(400,140), wxDefaultSize);

// hier for the Textfield ???
theText = new wxTextCtrl( this,
-1,
wxString("This is a text control\n\n"
"in the Action frame"
),
wxPoint(20,60),
wxSize(300,100),
wxTE_MULTILINE);


label = new wxStaticText(this, -1, wxString("Please give the actions :\n"),
wxPoint(20,20),
wxDefaultSize, wxST_NO_AUTORESIZE);
}
//------------------------------------------------------------------------------
void ActionFrame::OnQuit(wxCommandEvent& WXUNUSED(event)){
Close(true);
}
//------------------------------------------------------------------------------
void ActionFrame::OnOK(wxCommandEvent& WXUNUSED(event)){

}
//------------------------------------------------------------------------------
void ActionFrame::OnClear(wxCommandEvent& WXUNUSED(event)){
theText->Clear(); //clears the content of the TextCtrl

}
//------------------------------------------------------------------------------

merci encore.

1 réponse

assekkal Messages postés 3 Date d'inscription dimanche 8 juin 2003 Statut Membre Dernière intervention 14 août 2006
20 déc. 2004 à 13:16
Salaut,
c´est vrai ce que tu as dis, ca amrche avec la fonktion Hide():

si tu veux fermer la fenetre dans laquel tu es, essaye avec this->Hide();
si c´est une autre fenetre que tu veux fermer: essaye avec : nomDeLaFenetre->Hide(); si dans ce cas le nom de la fenetre n´est reconnue par le programme alors tu dois declarer la fenetre dans le fichier frame.h (dans ton example).
j´espere que j´ai repondu a ta question.
bonne continuation.
0
Rejoignez-nous