Texto de un dialogo
Publicado por Federico (40 intervenciones) el 26/03/2009 14:27:47
Hola estoy intentando tomar el texto de un textbox en VisualC++, pero me retorna vacio la cadena aqui les posteo el codigo
/*Creo el textBox*/
HWND hCntl;
hCntl = CreateWindowEx(0, L"EDIT" , L"", ES_LEFT | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 140, 10, 200, 20, hWnd, (HMENU)IDC_TXTUSER, NULL, NULL);
/*Le pongo texto, hasta aca funciona perfectamente*/
SetDlgItemText(hWnd,IDC_TXTUSER, L"Prueba");
/*Tomo la longitud del texto*/
DWORD dwLength = 0;
dwLength = SendMessage(GetDlgItem(hWnd,IDC_TXTUSER), WM_GETTEXTLENGTH, 0, 0) ;
/*La longitud es la correcta*/
UINT Ret = 0;
LPWSTR s = L"";
Ret = GetDlgItemText(hWnd,IDC_TXTUSER,s,dwLength);
He probado con varios tipos para s pero de ninguna forma pude logralo, les agradazco su tiempo. El valor de Ret, por lo que tengo entendido la funcion fallo al recuperar el valor.
/*Creo el textBox*/
HWND hCntl;
hCntl = CreateWindowEx(0, L"EDIT" , L"", ES_LEFT | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 140, 10, 200, 20, hWnd, (HMENU)IDC_TXTUSER, NULL, NULL);
/*Le pongo texto, hasta aca funciona perfectamente*/
SetDlgItemText(hWnd,IDC_TXTUSER, L"Prueba");
/*Tomo la longitud del texto*/
DWORD dwLength = 0;
dwLength = SendMessage(GetDlgItem(hWnd,IDC_TXTUSER), WM_GETTEXTLENGTH, 0, 0) ;
/*La longitud es la correcta*/
UINT Ret = 0;
LPWSTR s = L"";
Ret = GetDlgItemText(hWnd,IDC_TXTUSER,s,dwLength);
He probado con varios tipos para s pero de ninguna forma pude logralo, les agradazco su tiempo. El valor de Ret, por lo que tengo entendido la funcion fallo al recuperar el valor.
Valora esta pregunta


0