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 :

Recupere un CString d'une MRU [Fait]


Sujet :

MFC

  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    51
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2006
    Messages : 51
    Par défaut Recupere un CString d'une MRU
    Bonjour,

    je ne trouve pas dans la MSDN comment récupérer les Cstring que l'on a entré dans la liste des MostRecently Used (MRU)

    http://msdn2.microsoft.com/en-us/library/5a5b36d5.aspx

    http://msdn2.microsoft.com/en-us/library/kayts37a.aspx

    Quelqu'un a-t'il déjà utilisé ça ou à-t'il une idée pour m'aiser?

    merci

  2. #2
    Rédacteur
    Avatar de farscape
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Novembre 2003
    Messages
    9 055
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2003
    Messages : 9 055
    Par défaut
    salut de ce que j'ai pu voir ,
    les MFC lisent la liste avec un objet CRecentFileList dont le pointeur est stocké dans la classe d'application.
    donc:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
     #include <afxadv.h> // a mettre dans stdafx.h
        CString str;
        for( int i=0;m_pRecentFileList->GetSize( );i++)
            str=(*m_pRecentFileList)[i];

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    51
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2006
    Messages : 51
    Par défaut
    Merci beaucoup Farscape

  4. #4
    Membre averti
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    51
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2006
    Messages : 51
    Par défaut
    Je viens de regarder ce que tu viens de me montrer, et dans le fichier afxadv.h il n'y a pas d'attribut du nom de m_pRecentFileList. Tu le trouve ou cet attribut?

  5. #5
    Rédacteur
    Avatar de farscape
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Novembre 2003
    Messages
    9 055
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2003
    Messages : 9 055
    Par défaut
    en fait je suis allé fouiner dans la classe d'application et regarder la fonction:
    LoadStdProfileSettings qui manipule cette variable qui est declarée protected dans la classe d'application.
    tu as besoin de ce .h pour la classe CRecentFileList

  6. #6
    Membre averti
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    51
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2006
    Messages : 51
    Par défaut
    en fait je suis allé fouiner dans la classe d'application et regarder la fonction:
    LoadStdProfileSettings qui manipule cette variable qui est declarée protected dans la classe d'application.
    J'utilise la fonction LoadStdProfileSettings, mais je ne vois pas où tu vois qu'elle manipule cette variable? C'est dans la MSDN?

  7. #7
    Rédacteur
    Avatar de farscape
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Novembre 2003
    Messages
    9 055
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2003
    Messages : 9 055
    Par défaut
    nan dans le code des MFC
    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
     
    void CWinApp::LoadStdProfileSettings(UINT nMaxMRU)
    {
        ASSERT_VALID(this);
        ASSERT(m_pRecentFileList == NULL);
     
        if (nMaxMRU != 0)
        {
            // create file MRU since nMaxMRU not zero
            m_pRecentFileList = new CRecentFileList(0, _afxFileSection, _afxFileEntry,
                nMaxMRU);
            m_pRecentFileList->ReadList();
        }
        // 0 by default means not set
        m_nNumPreviewPages = GetProfileInt(_afxPreviewSection, _afxPreviewEntry, 0);
    }

  8. #8
    Membre averti
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    51
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2006
    Messages : 51
    Par défaut
    oui c'est vrai tu as tout à fait raison, je viens de voir ça. Pourtant je ne m'explique pas alors qu'à la compilation j'ai les erreurs suivantes:

    ValidProd3Doc.cpp(119) : error C2065: 'm_pRecentFileList' : undeclared identifier
    ValidProd3Doc.cpp(119) : error C2227: left of '->GetSize' must point to class/struct/union
    ValidProd3Doc.cpp(120) : error C2100: illegal indirection
    ValidProd3Doc.cpp(120) : error C2109: subscript requires array or pointer type

  9. #9
    Rédacteur
    Avatar de farscape
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Novembre 2003
    Messages
    9 055
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2003
    Messages : 9 055
    Par défaut
    ben c'est parce que tu n'as pas mis le header que je t'ai indiqué ?
    à mettre dans stdafx.h
    et recompiler stadfx.cpp
    j'ai fais l'essai ça compil/link sans problemes...

  10. #10
    Membre averti
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    51
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2006
    Messages : 51
    Par défaut
    si si j'ai bien mis le fichier .h dans stdafx.h.

    Mon problème ne viendrait-il plutôt pas du fait qu'il faut que je passe par un getter (par exemple AfxGetApp()) pour pouvoir accéder à cette variable 'm_pRecentFileList' membre de CWinApp::LoadStdProfileSettings?

  11. #11
    Rédacteur
    Avatar de farscape
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Novembre 2003
    Messages
    9 055
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2003
    Messages : 9 055
    Par défaut
    ah ben oui c'est sur ... la variable est protected (je l'ai signalé plus haut).
    dans la classe d'application il n' y a pas de probleme ...

  12. #12
    Membre averti
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    51
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2006
    Messages : 51
    Par défaut
    Si je comprend bien je ne peux pas y accéder à partir de ma [...]Doc mais seulemnt de ma classe d'application?

  13. #13
    Rédacteur
    Avatar de farscape
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Novembre 2003
    Messages
    9 055
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2003
    Messages : 9 055
    Par défaut
    Citation Envoyé par bubulle63
    Si je comprend bien je ne peux pas y accéder à partir de ma [...]Doc mais seulemnt de ma classe d'application?
    non je n'ai pas dit ça ! lol
    Citation Envoyé par farscape
    ah ben oui c'est sur ... la variable est protected (je l'ai signalé plus haut).
    dans la classe d'application il n' y a pas de probleme ...
    donc pour l'exterieur il faudra faire une fonction accesseur ...

    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
     
    class CTestToolBarApp : public CWinApp
    {
    public:
        CTestToolBarApp();
        inline CRecentFileList *GetRecentFileList(){return m_pRecentFileList;}
    //...
    };
    void CTestToolBarView::OnInitialUpdate()
    {
    //...
      CTestToolBarApp *TheApp=static_cast<CTestToolBarApp *>(AfxGetApp());
     
        CString str;
        for( int i=0;TheApp->GetRecentFileList()->GetSize( );i++)
            str=(*TheApp->GetRecentFileList())[i];
    }
    c'est plus clair ?

  14. #14
    Membre averti
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    51
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2006
    Messages : 51
    Par défaut
    Oui, c'est plus clair


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    void CTestToolBarView::OnInitialUpdate()
    {
    //...
      CTestToolBarApp *TheApp=static_cast<CTestToolBarApp *>(AfxGetApp());
     
        CString str;
        for( int i=0;TheApp->GetRecentFileList()->GetSize( );i++)
            str=(*TheApp->GetRecentFileList())[i];
    }
    mais, on est obligé de mettre ça dans [...]View::OnInitialUpdate? car moi c'est dans une autre classe que je pensais y mettre, par exemple :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    void ValidProd3Doc::XXXXX(...)
    {
      CString str;
     
     for( int i=0;GetVP3App()->GetScriptRecent()->GetSize( );i++)
            str=(*GetVP3App()->GetScriptRecent())[i];
     
     }
    et donc a la compilation j'ai les erreures suivantes :

    ValidProd3Doc.cpp(119) : error C2027: use of undefined type 'CRecentFileList'
    c:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(3930) : see declaration of 'CRecentFileList'
    ValidProd3Doc.cpp(119) : error C2227: left of '->GetSize' must point to class/struct/union
    ValidProd3Doc.cpp(120) : error C2676: binary '[' : 'class CRecentFileList' does not define this operator or a conversion to a type acceptable to the predefined operator

  15. #15
    Rédacteur
    Avatar de farscape
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Novembre 2003
    Messages
    9 055
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2003
    Messages : 9 055
    Par défaut
    heu , c'est un exemple ! tu l'utilise ou tu veux .
    est tu vraiment sur d'avoir rajouté:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    #include <afxadv.h>
    dans le fichier stdafx.h ?
    si c'est le cas tente de faire un rebuild all.

  16. #16
    Membre averti
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    51
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2006
    Messages : 51
    Par défaut
    oui oui je l'avait bien fait je viens de reverifier, j'ai fait un rebuild all et........et ben non, j'ai toujours ses erreurs.

  17. #17
    Rédacteur
    Avatar de farscape
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Novembre 2003
    Messages
    9 055
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2003
    Messages : 9 055
    Par défaut
    tu peux me montrer le contenu de ton stdafx.h ?

  18. #18
    Membre averti
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    51
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2006
    Messages : 51
    Par défaut
    // This is a part of the Microsoft Foundation Classes C++ library.
    // Copyright (C) 1992-1998 Microsoft Corporation
    // All rights reserved.
    //
    // This source code is only intended as a supplement to the
    // Microsoft Foundation Classes Reference and related
    // electronic documentation provided with the library.
    // See these sources for detailed information regarding the
    // Microsoft Foundation Classes product.
    // STDAFX.H is the header that includes the standard includes that are used
    // for most of the project. These are compiled into a pre-compiled header
    // turn off warnings for /W4 (just for MFC implementation)
    #ifndef ALL_WARNINGS
    #pragma warning(disable: 4073) // disable warning about using init_seg
    #endif
    // MFC inline constructors (including compiler generated) can get deep
    #pragma inline_depth(16)
    #ifdef _AFX_DEVBUILD
    #define AFX_IMPL_DATA AFX_DATA_EXPORT
    #else
    #define AFX_IMPL_DATA
    #endif
    // override default values for data import/export when building MFC DLLs
    #ifdef _AFX_CORE_IMPL
    #define AFX_CORE_DATA AFX_IMPL_DATA
    #define AFX_CORE_DATADEF
    #endif
    #ifdef _AFX_OLE_IMPL
    #define AFX_OLE_DATA AFX_IMPL_DATA
    #define AFX_OLE_DATADEF
    #endif
    #ifdef _AFX_DB_IMPL
    #define AFX_DB_DATA AFX_IMPL_DATA
    #define AFX_DB_DATADEF
    #endif
    #ifdef _AFX_NET_IMPL
    #define AFX_NET_DATA AFX_IMPL_DATA
    #define AFX_NET_DATADEF
    #endif
    #define _AFX_NOFORCE_LIBS
    #define _AFX_FULLTYPEINFO
    #define VC_EXTRALEAN
    #define NO_ANSIUNI_ONLY
    #define _MFC_OVERRIDES_NEW
    #define AFX_COMDAT __declspec(selectany)
    // core headers
    #include "afx.h"
    #include "afxplex_.h"
    #include "afxcoll.h"
    // public headers
    #include "afxwin.h"
    #include "afxdlgs.h"
    #include "afxext.h"

    //---------------------------------------------------------
    //Ajout pour la serialisation
    #include <afxadv.h>
    //-----------------------------------------------------------


    #ifndef _AFX_NO_OLEDB_SUPPORT
    #include "atlbase.h"
    #endif
    #ifndef _AFX_NO_OLE_SUPPORT
    #ifndef _OLE2_H_
    #include <ole2.h>
    #endif
    #include <winspool.h>
    // include OLE dialog/helper APIs
    #ifndef _OLEDLG_H_
    #include <oledlg.h>
    #endif
    #include <winreg.h>
    #include "afxcom_.h"
    #include "afxole.h"
    #include "afxdtctl.h"
    #include "afxdocob.h"
    #ifndef _AFX_NO_DAO_SUPPORT
    #include "afxdao.h"
    #endif
    #include "afxodlgs.h"
    #endif
    #ifndef _AFX_NO_OCX_SUPPORT
    #include "afxctl.h"
    #endif
    #ifndef _AFX_NO_DB_SUPPORT
    #include "afxdb.h"
    #endif
    #ifndef _AFX_NO_SYNC_SUPPORT
    #include "afxmt.h"
    #endif
    #ifndef _AFX_NO_INET_SUPPORT
    #include "afxinet.h"
    #endif
    // private headers as well
    #include "afxpriv.h"
    #include "afximpl.h"
    #include "winhand_.h"
    #ifndef _AFX_NO_OLE_SUPPORT
    #include "oleimpl2.h"
    #endif
    #ifndef _AFX_NO_OCX_SUPPORT
    #include "ctlimpl.h"
    #endif
    #ifndef _AFX_NO_DB_SUPPORT
    #include "dbimpl.h"
    #endif
    #ifndef _AFX_NO_DAO_SUPPORT
    #include "daoimpl.h"
    #endif
    #ifndef _AFX_NO_SOCKET_SUPPORT
    #ifndef _WINSOCKAPI_
    #include <winsock.h>
    #endif
    #include "sockimpl.h"
    #include "afxsock.h"
    #endif
    #ifndef _AFX_NO_AFXCMN_SUPPORT
    #include "afxcmn.h"
    #include "afxcview.h"
    #endif
    #ifndef _AFX_NO_RICHEDIT_SUPPORT
    #include "afxrich.h"
    #endif
    #ifndef _AFX_NO_DHTML_SUPPORT
    #include "afxhtml.h"
    #endif
    #include <winreg.h>
    #include <winnls.h>
    #include <stddef.h>
    #include <limits.h>
    #include <malloc.h>
    #include <new.h>
    #ifndef _AFX_OLD_EXCEPTIONS
    #include <eh.h> // for set_terminate
    #endif
    #undef AfxWndProc
    // implementation uses _AFX_PACKING as well
    #ifdef _AFX_PACKING
    #ifndef ALL_WARNINGS
    #pragma warning(disable: 4103)
    #endif
    #pragma pack(_AFX_PACKING)
    #endif
    // special exception handling just for MFC library implementation
    #ifndef _AFX_OLD_EXCEPTIONS
    // MFC does not rely on auto-delete semantics of the TRY..CATCH macros,
    // therefore those macros are mapped to something closer to the native
    // C++ exception handling mechanism when building MFC itself.
    #undef TRY
    #define TRY { try {
    #undef CATCH
    #define CATCH(class, e) } catch (class* e) \
    { ASSERT(e->IsKindOf(RUNTIME_CLASS(class))); UNUSED(e);
    #undef AND_CATCH
    #define AND_CATCH(class, e) } catch (class* e) \
    { ASSERT(e->IsKindOf(RUNTIME_CLASS(class))); UNUSED(e);
    #undef CATCH_ALL
    #define CATCH_ALL(e) } catch (CException* e) \
    { { ASSERT(e->IsKindOf(RUNTIME_CLASS(CException))); UNUSED(e);
    #undef AND_CATCH_ALL
    #define AND_CATCH_ALL(e) } catch (CException* e) \
    { { ASSERT(e->IsKindOf(RUNTIME_CLASS(CException))); UNUSED(e);
    #undef END_TRY
    #define END_TRY } catch (CException* e) \
    { ASSERT(e->IsKindOf(RUNTIME_CLASS(CException))); e->Delete(); } }
    #undef THROW_LAST
    #define THROW_LAST() throw
    // Because of the above definitions of TRY...CATCH it is necessary to
    // explicitly delete exception objects at the catch site.
    #define DELETE_EXCEPTION(e) do { e->Delete(); } while (0)
    #define NO_CPP_EXCEPTION(expr)
    #else //!_AFX_OLD_EXCEPTIONS
    // In this case, the TRY..CATCH macros provide auto-delete semantics, so
    // it is not necessary to explicitly delete exception objects at the catch site.
    #define DELETE_EXCEPTION(e)
    #define NO_CPP_EXCEPTION(expr) expr
    #endif //_AFX_OLD_EXCEPTIONS
    /////////////////////////////////////////////////////////////////////////////
    Voilà

  19. #19
    Membre averti
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    51
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2006
    Messages : 51
    Par défaut
    Est-ce que j'y est mis pas au bon endroit?

  20. #20
    Rédacteur
    Avatar de farscape
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Novembre 2003
    Messages
    9 055
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2003
    Messages : 9 055
    Par défaut
    ,heu c'est pas le stdafx.h de ton projet ça ?
    la ça ressemble fort au stdafx.h contenu dans les repertoires des MFC ...
    C:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC.

    pourquoi tu es allé modifié ça ?
    dans le repertoire de ton projet tu as un stdafx.h c'est celui la qu'il faut toucher.

+ Répondre à la discussion
Cette discussion est résolue.
Page 1 sur 2 12 DernièreDernière

Discussions similaires

  1. [JSP][WEB] recuperer le contenu d'une page web
    Par ypikahe dans le forum Servlets/JSP
    Réponses: 6
    Dernier message: 14/03/2008, 10h10
  2. [VB6] [Système] Récupérer le contenu d'une fenêtre DOS
    Par Nounours666 dans le forum VB 6 et antérieur
    Réponses: 16
    Dernier message: 18/11/2004, 16h38
  3. [C#] Recuperation de valeur dans une autre page
    Par kenzo080 dans le forum ASP.NET
    Réponses: 8
    Dernier message: 02/06/2004, 10h32
  4. [JSP][Debutant]recuperer un objet d'une page a l'autre
    Par zozolh2 dans le forum Servlets/JSP
    Réponses: 2
    Dernier message: 17/05/2004, 10h25
  5. Recuperation du source d'une page - envoi de param
    Par ulysse66x dans le forum Web & réseau
    Réponses: 3
    Dernier message: 15/06/2003, 17h31

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