Hello! For the first time I ran into WinAPI and I can’t transfer text from one edit to another on the fly. In this case, it is necessary that the text be ultimately displayed according to the rule “an odd character in upper case, even in lower case”. Here is my code. That in case WM_CHAR does not work.
#include <windows.h> LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow) { TCHAR szClassName[] = L"Мой класс"; HWND hMainWnd; MSG msg; WNDCLASSEX wc; wc.cbSize = sizeof(wc); wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = WndProc; wc.lpszMenuName = NULL; wc.lpszClassName = szClassName; wc.cbWndExtra = NULL; wc.cbClsExtra = NULL; wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); wc.hIconSm = LoadIcon(NULL, IDI_WINLOGO); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wc.hInstance = hInst; if (!RegisterClassEx(&wc)) { MessageBox(NULL, L"Не получилось зарегистрировать класс!", L"Ошибка", MB_OK); return NULL; } hMainWnd = CreateWindow( szClassName, L"Laba", WS_OVERLAPPEDWINDOW | WS_VSCROLL, CW_USEDEFAULT, NULL, CW_USEDEFAULT, NULL, (HWND)NULL, NULL, HINSTANCE(hInst), NULL); if (!hMainWnd) { MessageBox(NULL, L"Не получилось создать окно!", L"Ошибка", MB_OK); return NULL; } ShowWindow(hMainWnd, nCmdShow); UpdateWindow(hMainWnd); while (GetMessage(&msg, NULL, NULL, NULL)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; } LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { TCHAR buf[256]; HWND textbox; HWND textbox1; switch (uMsg) { case WM_CREATE: textbox = CreateWindowEx(WS_EX_CLIENTEDGE, L"EDIT", L"", WS_BORDER | WS_VISIBLE | WS_CHILD | ES_LEFT, 50, 50, 200, 50, hWnd, (HMENU)hWnd, NULL, NULL); ShowWindow(textbox, SW_NORMAL); UpdateWindow(textbox); textbox1 = CreateWindowEx(WS_EX_CLIENTEDGE, L"EDIT", L"", WS_BORDER | WS_VISIBLE | WS_CHILD | ES_LEFT, 50, 100, 200, 50, hWnd, (HMENU)hWnd, NULL, NULL); ShowWindow(textbox1, SW_NORMAL); UpdateWindow(textbox1); break; case WM_CHAR: GetWindowText(textbox, buf, sizeof(buf) / sizeof(buf[0])); SendMessage(textbox1, WM_SETTEXT, 0, (LPARAM)buf); break; case WM_DESTROY: PostQuitMessage(NULL); break; default: return DefWindowProc(hWnd, uMsg, wParam, lParam); } return NULL; }
textboxhandler - Harry