/*++ Copyright (C) 1993-1999 Microsoft Corporation Module Name: strtable.cpp Abstract: Implementation of a string table handler. The CStringTable class hides details of storage from the user. The strings might be cached, or they might be loaded as necessary. In either case, we must know the number of strings so we know whether or not to reload strings. --*/ #include #include #include "polyline.h" #include "strtable.h" // Create global instance of table CStringTable StringTable; /* * CStringTable::CStringTable * CStringTable::~CStringTable * * Constructor Parameters: * hInst HANDLE to the application instance from which we * load strings. */ CStringTable::CStringTable(void) { m_ppszTable = NULL; } CStringTable::~CStringTable(void) { INT i; // Free the loaded strings and table if (NULL != m_ppszTable) { for (i=0; i m_idsMax) return szMissing; // if already loaded, return it if (m_ppszTable[uID - m_idsMin] != NULL) return m_ppszTable[uID - m_idsMin]; BEGIN_CRITICAL_SECTION // if selected string not loaded, load it now if (m_ppszTable[uID - m_idsMin] == NULL) { iLen = LoadString(g_hInstance, uID, szBuf, CCHSTRINGMAX - 1); if (iLen == 0) lstrcpy(szBuf, szMissing); psz = (LPTSTR)malloc((iLen + 1) * sizeof(TCHAR)); if (psz != NULL) { lstrcpy(psz, szBuf); m_ppszTable[uID - m_idsMin] = psz; } } END_CRITICAL_SECTION // Now return selected pointer return m_ppszTable[uID - m_idsMin]; }