Advertisement
AleksandarH

(Old) PS - Calculation

May 11th, 2022 (edited)
667
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. double x1, x2, x3, sum;
  4. char t1[10], t11[10], t2[10], t22[10], t3[10], * stopstring;
  5.  
  6. // x1
  7. if ((IsDlgButtonChecked(hDlg, IDC_CHECK1)))
  8. {
  9.     GetDlgItemText(hDlg, IDC_EDIT2, t1, 100);
  10.     x1 = strtod(t1,&stopstring);
  11. }
  12. else
  13. {
  14.     x1 = 0;
  15. }
  16.  
  17. // x2
  18. if ((IsDlgButtonChecked(hDlg, IDC_CHECK2)))
  19. {
  20.     GetDlgItemText(hDlg, IDC_EDIT3, t2, 100);
  21.     x2 = strtod(t2, &stopstring);
  22. }
  23. else
  24. {
  25.     x2 = 0;
  26. }
  27.  
  28. // x3
  29. if ((IsDlgButtonChecked(hDlg, IDC_CHECK3)))
  30. {
  31.     cbIndex = SendDlgItemMessage(hDlg, IDC_COMBO2, CB_GETCURSEL, 0, 0);
  32.     if (cbIndex > -1)
  33.     {
  34.         SendDlgItemMessage(hDlg, IDC_COMBO2, CB_GETLBTEXT, cbIndex, (LPARAM)data);
  35.     }
  36.     x3 = strtod(data, &stopstring);
  37. }
  38. else
  39. {
  40.     x3 = 0;
  41. }
  42.  
  43. // result
  44. sum = x1 + x2 + x3;
  45. sprintf_s(t22, "%6.3f", sum);
  46. SetDlgItemText(hDlg, IDC_EDIT4, t22);
Advertisement
RAW Paste Data Copied
Advertisement