#include <windows.h>
#include <string>
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { static HWND hTextBox;
switch (uMsg) { case WM_CREATE: { // Crear un TextBox
hTextBox = CreateWindowEx(0, "EDIT", "",
WS_CHILD | WS_VISIBLE | WS_BORDER | ES_AUTOHSCROLL,
10, 10, 200, 25, hwnd, NULL, NULL, NULL);
break;
}
case WM_COMMAND: { // Aquí puedes manejar comandos, si es necesario
break;
}
case WM_DESTROY: { PostQuitMessage(0);
break;
}
default:
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
return 0;
}
void SetIPAddress(HWND hTextBox, const std::string& ipAddress) { // Convertir std::string a LPCSTR
SetWindowTextA(hTextBox, ipAddress.c_str());
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int nShowCmd) { // Crear la ventana principal
HWND hwnd = CreateWindowEx(0, "STATIC", "Ejemplo de TextBox",
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 300, 200,
NULL, NULL, hInstance, NULL);
ShowWindow(hwnd, nShowCmd);
UpdateWindow(hwnd);
// Establecer la dirección IP en el TextBox
SetIPAddress(hTextBox, "192.168.1.1");
// Bucle de mensajes
MSG msg;
while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}