GME  13
RecentConnStrList.h
Go to the documentation of this file.
00001 
00002 #ifndef MGA_RECENTCONNSTRLIST_H
00003 #define MGA_RECENTCONNSTRLIST_H
00004 
00005 #include <vector>
00006 
00007 /*
00008         This class is based on the CRecentFileList class, but unfortunately we
00009         could not reuse it as it was, it is too coupled with files.
00010         We have to store connection strings, mask the password from them,
00011         abbreviate them appropriately, etc. The usage should be similar to
00012         the original CRecentFileList.
00013 */
00014 
00015 class CRecentConnStrList
00016 {
00017 // Constructors
00018 public:
00019         CRecentConnStrList(UINT nStart, LPCTSTR lpszSection,
00020                 LPCTSTR lpszEntryFormat, int nSize,
00021                 int nMaxDispLen = 40);
00022 
00023 // Attributes
00024         int GetSize() const { return m_arrNames.size(); }
00025         CString& operator[](int nIndex) 
00026         { return m_arrNames[nIndex]; }
00027 
00028 // Operations
00029         BOOL GetDisplayName(CString& strName, int nIndex) const;
00030         void UpdateMenu(CCmdUI* pCmdUI,bool enable);
00031         void ReadList();    // reads from registry or ini file
00032         void AddAndWriteList(LPCTSTR lpszConnName);
00033 
00034         // Implementation
00035         virtual ~CRecentConnStrList();
00036 
00037 private:
00038         void Add(LPCTSTR lpszConnName);
00039         void Remove(int nIndex);
00040         void WriteList();   // writes to registry or ini file
00041 
00042         std::vector<CString> m_arrNames;
00043         CString m_strSectionName;   // for saving
00044         CString m_strEntryFormat;
00045         UINT m_nStart;              // for displaying
00046         int m_nMaxDisplayLength;
00047         CString m_strOriginal;      // original menu item contents
00048 };
00049 
00050 #endif//MGA_RECENTCONNSTRLIST_H