IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

MFC Discussion :

comment récuperer le texte dans un editview


Sujet :

MFC

  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    15
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2004
    Messages : 15
    Par défaut comment récuperer le texte dans un editview
    bonjour

    j'ai essayer avec GetWindowText
    http://c.developpez.com/faq/vc/?page=CWnd#GetWindowText

    en faites je voudrai enregistrer le fichier en appleant le programme de simulation

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    /*Methode lançant l'application Simulation "Simul" sous forme de processus,
    lorsqu'on appuie sur "simuler".
    C'est a dire que la fenetre principale n'est pas bloquée*/
    void CMicrotourApp::OnSimuler() 
    { 
     
     
     
    	STARTUPINFO         siStartupInfo;
    	PROCESS_INFORMATION piProcessInfo;
     
    	memset(&siStartupInfo, 0, sizeof(siStartupInfo));
    	memset(&piProcessInfo, 0, sizeof(piProcessInfo));
    	siStartupInfo.cb = sizeof(siStartupInfo);
    	if(CreateProcess("\\simul.exe",
    						 0,0,0,FALSE,
    						 CREATE_DEFAULT_ERROR_MODE,0,0,                              
    						 &siStartupInfo,&piProcessInfo) == FALSE)
    	{
    		AfxMessageBox("Le logiciel est inexistant"); 
    	}
    }
    mer ci d'avance

  2. #2
    Membre confirmé Avatar de loupdeau
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    125
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2005
    Messages : 125
    Par défaut
    Il dit qu'il voit pas le rapport...

    Est-ce que tu pourrais réexpliquer ce qu'est exactement ton problème ?

    La j'ai vraiment rien compris...

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    15
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2004
    Messages : 15
    Par défaut
    Citation Envoyé par loupdeau
    Il dit qu'il voit pas le rapport...

    Est-ce que tu pourrais réexpliquer ce qu'est exactement ton problème ?

    La j'ai vraiment rien compris...
    ben en faite je voudrai enregistrer mon fichier en appelant la methode OnSimuler() qui appele le programme simuler et qui qui en meme temp enregistre ce que j'ai dans le wiew mais le fichier enregistrer doir etre placer dans le dossiere source des programmes

  4. #4
    Membre confirmé Avatar de loupdeau
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    125
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2005
    Messages : 125
    Par défaut
    Donc en fait t'as pas de souci avec ton simul.exe.
    L'ecriture dans le fichier c'est une seconde chose qui n'a rien a voir avec ca... ?

    Si j'ai bien compris essaye d'utiliser ca :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
     
    //Création du fichier
    CFile m_File; 
     
    CString filename = "tonFichier.txt";
     
    char* pFileName = filename.GetBuffer(0);
    TRY
    {
      m_File.Open( pFileName, CFile::modeCreate | CFile::modeWrite );
    }
    CATCH( CFileException, e )
    {
    #ifdef _DEBUG
    		afxDump << "File could not be opened " << e->m_cause << "\n";
    #endif
    }
    END_CATCH
     
    //récupération du texte à écrire
    CString leTexte;
    tonMachin.GetWindowText(leTexte);
     
    //écriture dans le fichier
    m_File.Write(leTexte.GetBuffer(0),leTexte.GetLength());
     
    //fermeture du fichier
    m_File.Close();

  5. #5
    Membre averti
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    15
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2004
    Messages : 15
    Par défaut
    Citation Envoyé par loupdeau
    Donc en fait t'as pas de souci avec ton simul.exe.
    L'ecriture dans le fichier c'est une seconde chose qui n'a rien a voir avec ca... ?

    Si j'ai bien compris essaye d'utiliser ca :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
     
    //Création du fichier
    CFile m_File; 
     
    CString filename = "tonFichier.txt";
     
    char* pFileName = filename.GetBuffer(0);
    TRY
    {
      m_File.Open( pFileName, CFile::modeCreate | CFile::modeWrite );
    }
    CATCH( CFileException, e )
    {
    #ifdef _DEBUG
    		afxDump << "File could not be opened " << e->m_cause << "\n";
    #endif
    }
    END_CATCH
     
    //récupération du texte à écrire
    CString leTexte;
    tonMachin.GetWindowText(leTexte);
     
    //écriture dans le fichier
    m_File.Write(leTexte.GetBuffer(0),leTexte.GetLength());
     
    //fermeture du fichier
    m_File.Close();
    merci juste une petite question tu sai pas comment je peut trouver la variable qui est dans la classe Ceditwiew genéré par visual

    je voi pas comment ramplacer tonmachin que ta mit

  6. #6
    Membre confirmé Avatar de loupdeau
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    125
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2005
    Messages : 125
    Par défaut
    TonMachin = Ta CEditView (enfin je crois)


    ton texte il provient d'où ???

  7. #7
    Membre averti
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    15
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2004
    Messages : 15
    Par défaut
    Citation Envoyé par loupdeau
    TonMachin = Ta CEditView
    merci j'avez essayer sa mais ca me met

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    C:\microtour\microtour.cpp(202) : error C2143: syntax error : missing ';' before '.'
    C:\microtour\microtour.cpp(202) : error C2143: syntax error : missing ';' before '.'
    au 2 ligne la je vais chercher maerci beaucoup

  8. #8
    Membre averti
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    15
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2004
    Messages : 15
    Par défaut
    Citation Envoyé par loupdeau
    Le texte que tu veux écrire dans ton fichier il vient d'où ?
    ben ce bien la le pb je trouve pas j'ai avec²visual c qui a genere le editwiew mais j'ai aucune variable apprarente ou je ne la trouve pas

  9. #9
    Membre confirmé Avatar de loupdeau
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    125
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2005
    Messages : 125
    Par défaut
    La fonction OnSimuler se trouve dans la classe application.

    Comment est-ce que tu accède à la classe CEditView ???

  10. #10
    Membre averti
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    15
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2004
    Messages : 15
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    #if !defined(AFX_MICROTOURVIEW_H__BF6C8956_6F68_46AF_A333_DE3475B08D8D__INCLUDED_)
    #define AFX_MICROTOURVIEW_H__BF6C8956_6F68_46AF_A333_DE3475B08D8D__INCLUDED_
     
    #if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000
     
     
    class CMicrotourView : public CEditView
    {
    protected: // create from serialization only
    	CMicrotourView();
    	DECLARE_DYNCREATE(CMicrotourView)
     
    // Attributes
    public:
    	CMicrotourDoc* GetDocument();
     
    // Operations
    public:
     
    // Overrides
    	// ClassWizard generated virtual function overrides
    	//{{AFX_VIRTUAL(CMicrotourView)
    	public:
    	virtual void OnDraw(CDC* pDC);  // overridden to draw this view
    	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
    	protected:
    	virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
    	virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
    	virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
     
    	//}}AFX_VIRTUAL
     
    // Implementation
    public:
     
    	virtual ~CMicrotourView();
    #ifdef _DEBUG
    	virtual void AssertValid() const;
    	virtual void Dump(CDumpContext& dc) const;
     
     
    #endif
    protected:
     
    // Generated message map functions
    protected:
    	//{{AFX_MSG(CMicrotourView)
    		// NOTE - the ClassWizard will add and remove member functions here.
    	afx_msg	void OnOnglet();
    		//    DO NOT EDIT what you see in these blocks of generated code !CMicrotourView
    	//}}AFX_MSG
    	DECLARE_MESSAGE_MAP()
    };
     
    #ifndef _DEBUG  // debug version in microtourView.cpp
    inline CMicrotourDoc* CMicrotourView::GetDocument()
       { return (CMicrotourDoc*)m_pDocument; }
    #endif
     
    /////////////////////////////////////////////////////////////////////////////
     
    //{{AFX_INSERT_LOCATION}}
    // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
     
    #endif // !defined(AFX_MICROTOURVIEW_H__BF6C8956_6F68_46AF_A333_DE3475B08D8D__INCLUDED_)

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    #include "stdafx.h"
    #include "microtour.h"
     
    #include "microtourDoc.h"
    #include "microtourView.h"
     
    #ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endif
     
    /////////////////////////////////////////////////////////////////////////////
    // CMicrotourView
     
    IMPLEMENT_DYNCREATE(CMicrotourView, CEditView)
     
    BEGIN_MESSAGE_MAP(CMicrotourView, CEditView)
    	//{{AFX_MSG_MAP(CMicrotourView)
    		// NOTE - the ClassWizard will add and remove mapping macros here.
    			ON_COMMAND(ID_OUTIL_CONFIG, OnOnglet)
    		//    DO NOT EDIT what you see in these blocks of generated code!
    	//}}AFX_MSG_MAP
    	// Standard printing commands
    	ON_COMMAND(ID_FILE_PRINT, CEditView::OnFilePrint)
    	ON_COMMAND(ID_FILE_PRINT_DIRECT, CEditView::OnFilePrint)
    	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CEditView::OnFilePrintPreview)
    END_MESSAGE_MAP()
     
    /////////////////////////////////////////////////////////////////////////////
    // CMicrotourView construction/destruction
     
    CMicrotourView::CMicrotourView()
    {
    	// TODO: add construction code here
     
    }
     
    CMicrotourView::~CMicrotourView()
    {
    }
     
    BOOL CMicrotourView::PreCreateWindow(CREATESTRUCT& cs)
    {
    	// TODO: Modify the Window class or styles here by modifying
    	//  the CREATESTRUCT cs
     
    	BOOL bPreCreated = CEditView::PreCreateWindow(cs);
    	cs.style &= ~(ES_AUTOHSCROLL|WS_HSCROLL);	// Enable word-wrapping
     
    	return bPreCreated;
    }
     
    /////////////////////////////////////////////////////////////////////////////
    // CMicrotourView drawing
     
    void CMicrotourView::OnDraw(CDC* pDC)
    {
    	CMicrotourDoc* pDoc = GetDocument();
    	ASSERT_VALID(pDoc);
    	// TODO: add draw code for native data here
    }
     
    /////////////////////////////////////////////////////////////////////////////
    // CMicrotourView printing
     
    BOOL CMicrotourView::OnPreparePrinting(CPrintInfo* pInfo)
    {
    	// default CEditView preparation
    	return CEditView::OnPreparePrinting(pInfo);
    }
     
    void CMicrotourView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
    {
    	// Default CEditView begin printing.
    	CEditView::OnBeginPrinting(pDC, pInfo);
    }
     
    void CMicrotourView::OnEndPrinting(CDC* pDC, CPrintInfo* pInfo)
    {
    	// Default CEditView end printing
    	CEditView::OnEndPrinting(pDC, pInfo);
    }
     
     
    /////////////////////////////////////////////////////////////////////////////
    // CMicrotourView diagnostics
     
    #ifdef _DEBUG
    void CMicrotourView::AssertValid() const
    {
    	CEditView::AssertValid();
    }
     
    void CMicrotourView::Dump(CDumpContext& dc) const
    {
    	CEditView::Dump(dc);
    }
     
    CMicrotourDoc* CMicrotourView::GetDocument() // non-debug version is inline
    {
    	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMicrotourDoc)));
    	return (CMicrotourDoc*)m_pDocument;
    }
    #endif //_DEBUG
     
    /////////////////////////////////////////////////////////////////////////////
    // CMicrotourView message handlers
     
     
     
    void CMicrotourView::OnOnglet()
    {
    	Cconfig boite (_T("configuration "));
    	boite.DoModal();
    }

  11. #11
    Membre confirmé Avatar de loupdeau
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    125
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2005
    Messages : 125
    Par défaut
    tu crois que je vais m'amuser à lire tout ca ou quoi ???

    bon voila un truc qui marche :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    void CMainFrame::OnSimule() 
    {
    	CString leTexte;
     
    	CTonAppliView* maView = static_cast<CTonAppliView*>(((CFrameWnd *)AfxGetMainWnd())->GetActiveFrame()->GetActiveView()); 
     
    	maView->GetWindowText(leTexte);
     
    }
    pense à ajouter la ligne #include "CTonAppliView.h"


    dans le fichier CTonAppliView.h ajoute la ligne #include "CTonAppliDoc.h"


    Et normalement ca marche

  12. #12
    Membre averti
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    15
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2004
    Messages : 15
    Par défaut
    merci c'est cool

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [debutant] Comment organiser du texte dans un <td>?
    Par Jayceblaster dans le forum Balisage (X)HTML et validation W3C
    Réponses: 1
    Dernier message: 25/04/2006, 17h40
  2. Réponses: 7
    Dernier message: 17/03/2006, 13h26
  3. Comment envoyer du texte dans une fenêtre spéciale ?
    Par Coussati dans le forum Composants VCL
    Réponses: 11
    Dernier message: 25/10/2005, 09h00
  4. comment ecrire du texte dans une window application
    Par gaut dans le forum Autres éditeurs
    Réponses: 2
    Dernier message: 16/07/2003, 10h23
  5. Comment centrer un Texte dans un rectangle ...
    Par Djedjeridoo dans le forum Composants VCL
    Réponses: 3
    Dernier message: 16/06/2003, 21h56

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo