Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <math.h>
- #include <stdlib.h>
- HWND hedit, hedit2;
- int vl, vl2;
- LONG WINAPI WndProc(HWND, UINT, WPARAM, LPARAM);
- int WINAPI WinMain(HINSTANCE hInstance,
- HINSTANCE hPrevInstance,
- LPSTR lpCmdLine,
- int nCmdShow)
- {
- HWND hwnd;
- MSG msg;
- WNDCLASS w;
- memset(&w, 0, sizeof (WNDCLASS));
- w.style = CS_HREDRAW | CS_VREDRAW;
- w.lpfnWndProc = WndProc;
- w.hInstance = hInstance;
- w.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
- w.lpszClassName = "My Class";
- RegisterClass(&w);
- hwnd = CreateWindow("My Class", "primer",
- WS_OVERLAPPEDWINDOW,
- 500, 300, 500, 380, NULL, NULL, hInstance, NULL);
- hedit = CreateWindow("edit", "0", WS_CHILD | WS_VISIBLE | ES_LEFT,
- 10, 10, 80, 30, hwnd, (HMENU) 10000, hInstance, NULL);
- hedit2 = CreateWindow("edit", "0", WS_CHILD | WS_VISIBLE | ES_LEFT,
- 150, 10, 80, 30, hwnd, (HMENU) 10001, hInstance, NULL);
- CreateWindow("button", "+", WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON,
- 10, 100, 40, 20, hwnd, (HMENU) 1000, hInstance, NULL);
- ShowWindow(hwnd, nCmdShow);
- UpdateWindow(hwnd);
- while (GetMessage(&msg, NULL, 0, 0))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- return msg.wParam;
- }
- LONG WINAPI WndProc(HWND hwnd, UINT Message, WPARAM wparam, LPARAM lparam) {
- TCHAR val[33] = {0};
- switch (Message)
- {
- case WM_DESTROY: PostQuitMessage(0);
- break;
- case WM_COMMAND:
- {
- switch (LOWORD(wparam))
- {
- case 1000:
- {
- GetWindowText(hedit, val, 33);
- vl = atoi(val);
- GetWindowText(hedit2, val, 33);
- vl2 = atoi(val);
- int res = vl + vl2;
- itoa(res, val, 10);
- MessageBox(hwnd, LPSTR(resCHR), "Результат", MB_OK);
- }
- }
- };
- default: return DefWindowProc(hwnd, Message, wparam, lparam);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement