fork(1) download
  1. ////////////////////////////////////////////////////////////////////////////////
  2. // RadioButton.c
  3. #include <tchar.h>
  4. #include <Windows.h>
  5. #include <WindowsX.h>
  6. #include "resource.h"
  7.  
  8. INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  9. void OnOK(HWND hDlg);
  10.  
  11. int APIENTRY _tWinMain(
  12. HINSTANCE hInstance,
  13. HINSTANCE hPrevInstance,
  14. LPTSTR lpCmdLine,
  15. int nCmdShow)
  16. {
  17. DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG), NULL, DialogProc);
  18. return 0;
  19. }
  20.  
  21. INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  22. {
  23. INT_PTR iRetVal = TRUE;
  24.  
  25. switch (uMsg) {
  26. case WM_COMMAND:
  27. switch (LOWORD(wParam)) {
  28. case IDOK:
  29. OnOK(hwndDlg);
  30. break;
  31. }
  32. break;
  33. case WM_INITDIALOG:
  34. Button_SetCheck(GetDlgItem(hwndDlg, IDC_RADIO1), BST_CHECKED);
  35. break;
  36. case WM_CLOSE:
  37. EndDialog(hwndDlg, 0);
  38. break;
  39. default:
  40. iRetVal = FALSE;
  41. }
  42. return iRetVal;
  43. }
  44.  
  45. void OnOK(HWND hDlg)
  46. {
  47. LRESULT lr;
  48. int i1, i2, i3;
  49.  
  50. i1 = GetDlgItemInt(hDlg, IDC_EDIT1, NULL, TRUE);
  51. i2 = GetDlgItemInt(hDlg, IDC_EDIT2, NULL, TRUE);
  52. lr = Button_GetCheck(GetDlgItem(hDlg, IDC_RADIO1));
  53. if (lr == BST_CHECKED) {
  54. i3 = i1 + i2;
  55. } else {
  56. i3 = i1 - i2;
  57. }
  58. SetDlgItemInt(hDlg, IDC_EDIT3, i3, TRUE);
  59. }
  60.  
  61. ////////////////////////////////////////////////////////////////////////////////
  62. // resource.h
  63. #define IDD_DIALOG 100
  64.  
  65. #define IDC_STATIC -1
  66. #define IDC_EDIT1 1000
  67. #define IDC_EDIT2 1001
  68. #define IDC_EDIT3 1002
  69. #define IDC_RADIO1 1003
  70. #define IDC_RADIO2 1004
  71.  
  72. ////////////////////////////////////////////////////////////////////////////////
  73. // RadioButton.rc
  74. #include <windows.h>
  75. #include "resource.h"
  76.  
  77. IDD_DIALOG DIALOGEX 300, 200, 130, 55
  78. STYLE WS_POPUPWINDOW | WS_MINIMIZEBOX
  79. EXSTYLE WS_EX_APPWINDOW
  80. CAPTION "RadioButton"
  81. FONT 9, "MS Pゴシック"
  82. BEGIN
  83. EDITTEXT IDC_EDIT1,4,4,36,12
  84. EDITTEXT IDC_EDIT2,44,4,36,12
  85. EDITTEXT IDC_EDIT3,88,4,36,12
  86. CONTROL "+",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON | WS_GROUP,
  87. 8,32,28,12
  88. CONTROL "-",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON,
  89. 40,32,28,12
  90. GROUPBOX "演算子",IDC_STATIC,4,20,76,32,WS_GROUP
  91. DEFPUSHBUTTON "OK",IDOK,88,24,26,16
  92. END
  93.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty