1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
| #include<Windows.h> #include<CommCtrl.h> #include"resource.h"
INT_PTR CALLBACK Dlgproc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { switch (uMsg) { case WM_INITDIALOG: {
break; } case WM_CLOSE: { EndDialog(hwnd, 0); break; } case WM_COMMAND: { WORD ControlId = LOWORD(wParam); switch (ControlId) { case IDC_BUTTON1: { WCHAR buff[20]{ 0 }; for (UINT BTNID = IDC_CHECK1; BTNID <= IDC_CHECK3; BTNID++) { UINT Checked = SendDlgItemMessageW(hwnd, BTNID, BM_GETCHECK, 0, 0); if (Checked == BST_CHECKED) { GetDlgItemTextW(hwnd, BTNID, buff, 20); MessageBoxW(hwnd, buff, L"提示", MB_OK); } } break; } case IDC_BUTTON2: { WCHAR buff[20]{ 0 }; for (UINT BTNID = IDC_RADIO1; BTNID <= IDC_RADIO3; BTNID++) { UINT Checked = SendDlgItemMessageW(hwnd, BTNID, BM_GETCHECK, 0, 0); if (Checked == BST_CHECKED) { GetDlgItemTextW(hwnd, BTNID, buff, 20); MessageBoxW(hwnd, buff, L"提示", MB_OK); break; } } break; } default: break; } break; } default: break; } return FALSE; } int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd ) {
DialogBoxW(hInstance, MAKEINTRESOURCEW(IDD_DIALOG1), NULL, Dlgproc); return 0; }
|