Todo eso lo puedo hacer sin problema. Después para obtener los datos de la caja de texto use el mensaje EM_GETLINE. Esta solución me funciona bastante bien ya que después uso la función printf() para desplegar los datos.
En fin, lo raro es que cuando ejecuto el programa y escribo en la caja de texto: "Hola Mundo" el programa me imprime por pantalla el mensaje pero al final le añade una carita feliz. Si alguien pudiera explicarme este fenómeno y como evitarlo se lo agradecería.
Les dejo aquí un pedazo de código:
Código:
LRESULT CALLBACK Procedure(HWND hWindow, UINT message, WPARAM wParam, LPARAM lParam){
static HWND button, caja;
switch(message){
case WM_DESTROY:{
PostQuitMessage(0);
return 0;
}
case WM_CREATE:{
button = CreateWindowEx(WS_EX_CLIENTEDGE, "BUTTON", "BUTTON", WS_CHILD | WS_VISIBLE, 10, 10, 100, 50, hWindow, NULL, NULL, NULL);
caja = CreateWindowEx(WS_EX_ACCEPTFILES, "EDIT", "", WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL, 10, 70, 100, 25, hWindow, NULL, NULL, NULL);
break;
}
case WM_COMMAND:{
char buffer[512];
if((HWND)lParam == button){
[b]SendMessage(caja, EM_GETLINE, 0, (LPARAM)buffer);
printf("%d \n", strlen(buffer));
printf("%s\n", buffer);[/b]
return 0;
}
break;
}
}
return DefWindowProc(hWindow, message, wParam, lParam);
}
static HWND button, caja;
switch(message){
case WM_DESTROY:{
PostQuitMessage(0);
return 0;
}
case WM_CREATE:{
button = CreateWindowEx(WS_EX_CLIENTEDGE, "BUTTON", "BUTTON", WS_CHILD | WS_VISIBLE, 10, 10, 100, 50, hWindow, NULL, NULL, NULL);
caja = CreateWindowEx(WS_EX_ACCEPTFILES, "EDIT", "", WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL, 10, 70, 100, 25, hWindow, NULL, NULL, NULL);
break;
}
case WM_COMMAND:{
char buffer[512];
if((HWND)lParam == button){
[b]SendMessage(caja, EM_GETLINE, 0, (LPARAM)buffer);
printf("%d \n", strlen(buffer));
printf("%s\n", buffer);[/b]
return 0;
}
break;
}
}
return DefWindowProc(hWindow, message, wParam, lParam);
}