Hi all
In using the following code
i was losing the global string g_catstr
it seems that GetWindowTextLength may return a longer length than is actually in the control
having tried it with
GetDlgItemText(hDlg, ADDPART_PER_COMBO,st_part.perstr,12);
12 being initialised len of st_part.perstr
it works and does not overwrite g_catstr
so what is the best way to obtain len and not have to state a hardcoded figurelike 12
Ansi version
//int clen = GetWindowTextLength(GetDlgItem(hDlg, ADDPART_PER_COMBO));
Wide version
int clen = GetWindowTextLengthW(GetDlgItem(hDlg, ADDPART_PER_COMBO));
if (clen>0)
{
wchar_t xstr[50];
swprintf(xstr, L"%d",clen); //always evaluates to 26 for ansi or wide
CheckMemoryStatus();
MessageBox(g_hwnd,xstr, L"len is", MB_OK | MB_ICONINFORMATION);
MessageBox(g_hwnd,g_catstr, L"In AddEditDlog topOK", MB_OK | MB_ICONINFORMATION);
GetDlgItemText(hDlg, ADDPART_PER_COMBO,st_part.perstr,12);
if i use clen+1 it overwrites g_catstr and shows it as empty
//GetWindowText(GetDlgItem(hDlg, ADDPART_PER_COMBO),st_part.perstr,clen+1);
MessageBox(hDlg,st_part.perstr, L"per string INFO", MB_OK | MB_ICONINFORMATION);
MessageBox(g_hwnd,g_catstr, L"In AddEditPArtsDlog botOK", MB_OK | MB_ICONINFORMATION);
}