#include "Windows.h"
#include "tchar.h"
#include "resource.h"
INT_PTR CALLBACK DlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
HWND hplace1, hplace2, hstatic1;
int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nShowCmd)
{
return DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, DLGPROC(DlgProc));
}
INT_PTR CALLBACK DlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG: {
hplace1 = GetDlgItem(hwnd, IDC_EDIT1);
hplace2 = GetDlgItem(hwnd, IDC_EDIT2);
hstatic1 = GetDlgItem(hwnd, IDC_STATIC2);
}
break;
case WM_COMMAND:
{
LRESULT result = SendDlgItemMessage(hwnd, IDC_RADIO1, BM_GETCHECK, 0, 0);
if (result == BST_CHECKED && LOWORD(wParam) == IDC_RADIO1 && HIWORD(wParam) == BN_CLICKED)
{
wchar_t buffer1[256];
GetWindowText(hplace1, buffer1, sizeof(buffer1) / sizeof(buffer1[0]));
int value1 = _wtoi(buffer1);
wchar_t buffer2[256];
GetWindowText(hplace2, buffer2, sizeof(buffer2) / sizeof(buffer2[0]));
int value2 = _wtoi(buffer2);
int sum = value1 + value2;
wchar_t sumText[256];
swprintf_s(sumText, L"Сумма: %d", sum);
SetWindowText(hstatic1, sumText);
}
}
break;
case WM_CLOSE:
EndDialog(hwnd, 0);
return TRUE;
}
return FALSE;
}