Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- INT_PTR CALLBACK MathTest(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
- {
- int random1 = 0;
- int random2 = 0;
- int random3 = 0;
- // string a = "";
- int a = GetDlgItemInt(hDlg, IDC_A, NULL, true);
- int b = GetDlgItemInt(hDlg, IDC_B, NULL, true);
- int c = GetDlgItemInt(hDlg, IDC_C, NULL, true);
- int Correct = GetDlgItemInt(hDlg, IDC_CORRECT, NULL, true);
- int Wrong = GetDlgItemInt(hDlg, IDC_WRONG, NULL, true);
- char MathSymbol{};
- char Txt[20];
- UNREFERENCED_PARAMETER(lParam);
- switch (message)
- {
- case WM_INITDIALOG:
- CheckDlgButton(hDlg, IDC_PLUS, BST_CHECKED);
- CheckDlgButton(hDlg, IDC_1_20, BST_CHECKED);
- srand(time(0));
- return (INT_PTR)TRUE;
- case WM_COMMAND:
- if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
- {
- EndDialog(hDlg, LOWORD(wParam));
- return (INT_PTR)TRUE;
- }
- else if (LOWORD(wParam) == IDC_PLUS) {
- if (IsDlgButtonChecked(hDlg, IDC_1_20)) {
- int a = GetDlgItemInt(hDlg, IDC_A, NULL, true);
- int b = GetDlgItemInt(hDlg, IDC_B, NULL, true);
- int c = GetDlgItemInt(hDlg, IDC_C, NULL, true);
- SetDlgItemInt(hDlg, IDC_LIST, a + b + c,true);
- }
- }
- else if (LOWORD(wParam) == IDC_RANDOM) {
- srand(time(NULL));
- if (IsDlgButtonChecked(hDlg, IDC_1_20)) {
- random1 = rand() % (20 + 1 - 0) + 0;
- SetDlgItemInt(hDlg, IDC_A, random1, true);
- random2 = rand() % (20 + 1 - 0) + 0;
- SetDlgItemInt(hDlg, IDC_B, random2, true);
- random3 = rand() % (20 + 1 - 0) + 0;
- SetDlgItemInt(hDlg, IDC_C, random3, true);
- // int a = GetDlgItemInt(hDlg, IDC_A, NULL, true);
- //int b = GetDlgItemInt(hDlg, IDC_B, NULL, true);
- // int c = GetDlgItemInt(hDlg, IDC_C, NULL, true);
- }else if (IsDlgButtonChecked(hDlg, IDC_21_50)) {
- random1 = rand() % (50 + 1 - 21) + 21;
- SetDlgItemInt(hDlg, IDC_A, random1, true);
- random2 = rand() % (50 + 1 - 21) + 21;
- SetDlgItemInt(hDlg, IDC_B, random2, true);
- random3 = rand() % (50 + 1 - 21) + 21;
- SetDlgItemInt(hDlg, IDC_C, random3, true);
- }
- else if (IsDlgButtonChecked(hDlg, IDC_51_100)) {
- random1 = rand() % (100 + 1 - 51) + 51;
- SetDlgItemInt(hDlg, IDC_A, random1, true);
- random2 = rand() % (100 + 1 - 51) + 51;
- SetDlgItemInt(hDlg, IDC_B, random2, true);
- random3 = rand() % (100 + 1 - 51) + 51;
- SetDlgItemInt(hDlg, IDC_C, random3, true);
- }
- break;
- }
- else if (LOWORD(wParam) == IDC_FINISH) {
- a = (double)Correct / (Correct + Wrong) * 100;
- b = (double)Correct / (Correct + Wrong) * 100;
- c = (double)Correct / (Correct + Wrong) * 100;
- /*
- if(IsDlgButtonChecked(hDlg, IDC_PLUS) == true){
- }
- else if (IsDlgButtonChecked(hDlg, IDC_MINUS) == true) {
- }
- else if (IsDlgButtonChecked(hDlg, IDC_UMNOJ) == true) {
- }
- else if (IsDlgButtonChecked(hDlg, IDC_DEL) == true) {
- }
- GetDlgItemText(hDlg, IDC_A,(LPWSTR)aTxt, 20);
- SendDlgItemMessage(hDlg, IDC_LIST, LB_ADDSTRING, 0, (LPARAM)aTxt);
- if (IsDlgButtonChecked(hDlg, IDC_PLUS) == true) {
- MathSymbol = '+';
- }else if (IsDlgButtonChecked(hDlg, IDC_MINUS) == true) {
- MathSymbol = '-';
- }else if (IsDlgButtonChecked(hDlg, IDC_UMNOJ) == true) {
- MathSymbol = '*';
- }else if (IsDlgButtonChecked(hDlg, IDC_DEL) == true) {
- MathSymbol = '/';
- }
- char bTxt[20];
- GetDlgItemText(hDlg, IDC_B, (LPWSTR)bTxt, 20);
- SendDlgItemMessage(hDlg, IDC_LIST, LB_ADDSTRING, 0, (LPARAM)bTxt);
- if (IsDlgButtonChecked(hDlg, IDC_PLUS) == true) {
- MathSymbol = '+';
- }
- else if (IsDlgButtonChecked(hDlg, IDC_MINUS) == true) {
- MathSymbol = '-';
- }
- else if (IsDlgButtonChecked(hDlg, IDC_UMNOJ) == true) {
- MathSymbol = '*';
- }
- else if (IsDlgButtonChecked(hDlg, IDC_DEL) == true) {
- MathSymbol = '/';
- }
- char cTxt[20];
- GetDlgItemText(hDlg, IDC_C, (LPWSTR)cTxt, 20);
- SendDlgItemMessage(hDlg, IDC_LIST, LB_ADDSTRING, 0, (LPARAM)cTxt);
- if (IsDlgButtonChecked(hDlg, IDC_PLUS) == true) {
- MathSymbol = '+';
- }
- else if (IsDlgButtonChecked(hDlg, IDC_MINUS) == true) {
- MathSymbol = '-';
- }
- else if (IsDlgButtonChecked(hDlg, IDC_UMNOJ) == true) {
- MathSymbol = '*';
- }
- else if (IsDlgButtonChecked(hDlg, IDC_DEL) == true) {
- MathSymbol = '/';
- }*/
- }
- else if (LOWORD(wParam) == IDC_CLEAR) {
- SetDlgItemText(hDlg, IDC_A, 0);
- SetDlgItemText(hDlg, IDC_B, 0);
- SetDlgItemText(hDlg, IDC_C, 0);
- break;
- }
- else if (LOWORD(wParam) == IDC_CHECK) {
- int a = GetDlgItemInt(hDlg, IDC_A, NULL, true);
- int b = GetDlgItemInt(hDlg, IDC_B, NULL, true);
- int c = GetDlgItemInt(hDlg, IDC_C, NULL, true);
- if ((a + b) == c || (a - b) == c || (a * b) == c || (a / b) == c) {
- Correct++;
- SetDlgItemInt(hDlg, IDC_CORRECT, Correct, true);
- }
- else {
- Wrong++;
- SetDlgItemInt(hDlg, IDC_WRONG,Wrong, true);
- }
- if (IsDlgButtonChecked(hDlg, IDC_PLUS) == true) {
- MathSymbol = '+';
- }
- else if (IsDlgButtonChecked(hDlg, IDC_MINUS) == true) {
- MathSymbol = '-';
- }
- else if (IsDlgButtonChecked(hDlg, IDC_UMNOJ) == true) {
- MathSymbol = '*';
- }
- else if (IsDlgButtonChecked(hDlg, IDC_DEL) == true) {
- MathSymbol = '/';
- }
- string Txt = to_string(a) + MathSymbol + to_string(b) + '=' + to_string(c);
- }
- break;
- }
- return (INT_PTR)FALSE;
- }
Advertisement
Add Comment
Please, Sign In to add comment