////////////////////////////////////////////////////////////////////////////////
// RadioButton.c
#include <tchar.h>
#include <Windows.h>
#include <WindowsX.h>
#include "resource.h"
INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
void OnOK(HWND hDlg);
int APIENTRY _tWinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG), NULL, DialogProc);
return 0;
}
INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
INT_PTR iRetVal = TRUE;
switch (uMsg) {
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
OnOK(hwndDlg);
break;
}
break;
case WM_INITDIALOG:
Button_SetCheck(GetDlgItem(hwndDlg, IDC_RADIO1), BST_CHECKED);
break;
case WM_CLOSE:
EndDialog(hwndDlg, 0);
break;
default:
iRetVal = FALSE;
}
return iRetVal;
}
void OnOK(HWND hDlg)
{
LRESULT lr;
int i1, i2, i3;
i1 = GetDlgItemInt(hDlg, IDC_EDIT1, NULL, TRUE);
i2 = GetDlgItemInt(hDlg, IDC_EDIT2, NULL, TRUE);
lr = Button_GetCheck(GetDlgItem(hDlg, IDC_RADIO1));
if (lr == BST_CHECKED) {
i3 = i1 + i2;
} else {
i3 = i1 - i2;
}
SetDlgItemInt(hDlg, IDC_EDIT3, i3, TRUE);
}
////////////////////////////////////////////////////////////////////////////////
// resource.h
#define IDD_DIALOG 100
#define IDC_STATIC -1
#define IDC_EDIT1 1000
#define IDC_EDIT2 1001
#define IDC_EDIT3 1002
#define IDC_RADIO1 1003
#define IDC_RADIO2 1004
////////////////////////////////////////////////////////////////////////////////
// RadioButton.rc
#include <windows.h>
#include "resource.h"
IDD_DIALOG DIALOGEX 300, 200, 130, 55
STYLE WS_POPUPWINDOW | WS_MINIMIZEBOX
EXSTYLE WS_EX_APPWINDOW
CAPTION "RadioButton"
FONT 9, "MS Pゴシック"
BEGIN
EDITTEXT IDC_EDIT1,4,4,36,12
EDITTEXT IDC_EDIT2,44,4,36,12
EDITTEXT IDC_EDIT3,88,4,36,12
CONTROL "+",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON | WS_GROUP,
8,32,28,12
CONTROL "-",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON,
40,32,28,12
GROUPBOX "演算子",IDC_STATIC,4,20,76,32,WS_GROUP
DEFPUSHBUTTON "OK",IDOK,88,24,26,16
END
Ly8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8KLy8gUmFkaW9CdXR0b24uYwojaW5jbHVkZSA8dGNoYXIuaD4KI2luY2x1ZGUgPFdpbmRvd3MuaD4KI2luY2x1ZGUgPFdpbmRvd3NYLmg+CiNpbmNsdWRlICJyZXNvdXJjZS5oIgoKSU5UX1BUUiBDQUxMQkFDSyBEaWFsb2dQcm9jKEhXTkQgaHduZERsZywgVUlOVCB1TXNnLCBXUEFSQU0gd1BhcmFtLCBMUEFSQU0gbFBhcmFtKTsKdm9pZCBPbk9LKEhXTkQgaERsZyk7CgppbnQgQVBJRU5UUlkgX3RXaW5NYWluKAoJSElOU1RBTkNFCWhJbnN0YW5jZSwKCUhJTlNUQU5DRQloUHJldkluc3RhbmNlLAoJTFBUU1RSCQlscENtZExpbmUsCglpbnQJCW5DbWRTaG93KQp7CglEaWFsb2dCb3goaEluc3RhbmNlLCBNQUtFSU5UUkVTT1VSQ0UoSUREX0RJQUxPRyksIE5VTEwsIERpYWxvZ1Byb2MpOwoJcmV0dXJuIDA7Cn0KCklOVF9QVFIgQ0FMTEJBQ0sgRGlhbG9nUHJvYyhIV05EIGh3bmREbGcsIFVJTlQgdU1zZywgV1BBUkFNIHdQYXJhbSwgTFBBUkFNIGxQYXJhbSkKewoJSU5UX1BUUiBpUmV0Vm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