1// Windows/Control/ComboBox.cpp 2 3#include "StdAfx.h" 4 5#ifndef _UNICODE 6#include "../../Common/StringConvert.h" 7#endif 8 9#include "ComboBox.h" 10 11#ifndef _UNICODE 12extern bool g_IsNT; 13#endif 14 15namespace NWindows { 16namespace NControl { 17 18LRESULT CComboBox::GetLBText(int index, CSysString &s) 19{ 20 s.Empty(); 21 LRESULT len = GetLBTextLen(index); 22 if (len == CB_ERR) 23 return len; 24 len = GetLBText(index, s.GetBuffer((int)len + 1)); 25 s.ReleaseBuffer(); 26 return len; 27} 28 29#ifndef _UNICODE 30LRESULT CComboBox::AddString(LPCWSTR s) 31{ 32 if (g_IsNT) 33 return SendMessageW(CB_ADDSTRING, 0, (LPARAM)s); 34 return AddString(GetSystemString(s)); 35} 36 37LRESULT CComboBox::GetLBText(int index, UString &s) 38{ 39 s.Empty(); 40 if (g_IsNT) 41 { 42 LRESULT len = SendMessageW(CB_GETLBTEXTLEN, index, 0); 43 if (len == CB_ERR) 44 return len; 45 len = SendMessageW(CB_GETLBTEXT, index, (LPARAM)s.GetBuffer((int)len + 1)); 46 s.ReleaseBuffer(); 47 return len; 48 } 49 AString sa; 50 LRESULT len = GetLBText(index, sa); 51 if (len == CB_ERR) 52 return len; 53 s = GetUnicodeString(sa); 54 return s.Len(); 55} 56#endif 57 58}} 59