Windows support
| 2014 | |
| 2015 | // Windows support |
| 2016 | BOOL LoadString(UINT nID) // load from string resource (255 chars max.) |
| 2017 | { |
| 2018 | #ifdef _UNICODE |
| 2019 | const int CHAR_FUDGE = 1; // one TCHAR unused is good enough |
| 2020 | #else |
| 2021 | const int CHAR_FUDGE = 2; // two BYTES unused for case of DBC last char |
| 2022 | #endif |
| 2023 | |
| 2024 | // try fixed buffer first (to avoid wasting space in the heap) |
| 2025 | TCHAR szTemp[256]; |
| 2026 | int nCount = sizeof(szTemp) / sizeof(szTemp[0]); |
| 2027 | int nLen = _LoadString(nID, szTemp, nCount); |
| 2028 | if (nCount - nLen > CHAR_FUDGE) |
| 2029 | { |
| 2030 | *this = szTemp; |
| 2031 | return (nLen > 0); |
| 2032 | } |
| 2033 | |
| 2034 | // try buffer size of 512, then larger size until entire string is retrieved |
| 2035 | int nSize = 256; |
| 2036 | do |
| 2037 | { |
| 2038 | nSize += 256; |
| 2039 | LPTSTR lpstr = GetBuffer(nSize - 1); |
| 2040 | if(lpstr == NULL) |
| 2041 | { |
| 2042 | nLen = 0; |
| 2043 | break; |
| 2044 | } |
| 2045 | nLen = _LoadString(nID, lpstr, nSize); |
| 2046 | } while (nSize - nLen <= CHAR_FUDGE); |
| 2047 | ReleaseBuffer(); |
| 2048 | |
| 2049 | return (nLen > 0); |
| 2050 | } |
| 2051 | |
| 2052 | #ifndef _UNICODE |
| 2053 | // ANSI <-> OEM support (convert string in place) |
no outgoing calls
no test coverage detected