Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- #include <math.h>
- #include <list>
- #include <stdio.h>
- using namespace std;
- LPCSTR NazwaKlasy = TEXT("Klasa Okienka");
- MSG Komunikat;
- HDC hdc;
- HWND hwnd;
- RECT Rect;
- HWND hRadio1, hRadio2, hRadio3, hRadio4, hRadio5, hRadio6, hRadio7, hRadio8, hRadio9, hRadio10, hRadio11, hRadio12, hPytanie1, hPytanie2, hPytanie3, hPytanie4, hButtonCheck, wynik;
- LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
- bool wynik1, wynik2, wynik3, wynik4;
- char w1[50], w2[50], w3[50], w4[50], gotowy[500];
- int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
- {
- WNDCLASSEX wc;
- wc.cbSize = sizeof(WNDCLASSEX);
- wc.style = CS_HREDRAW | CS_VREDRAW;
- wc.lpfnWndProc = WndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = hInstance;
- wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
- wc.lpszMenuName = NULL;
- wc.lpszClassName = NazwaKlasy;
- wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
- if (!RegisterClassEx(&wc))
- {
- MessageBox(NULL, TEXT("Nie mozna utworzyc okna"), TEXT("Niestety..."),
- MB_ICONEXCLAMATION | MB_OK);
- return 1;
- }
- hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, NazwaKlasy, TEXT("Oto okienko"), WS_OVERLAPPEDWINDOW,
- CW_USEDEFAULT, CW_USEDEFAULT, 1000, 1000, NULL, NULL, hInstance, NULL);
- hRadio1 = CreateWindowEx(0, "BUTTON", "Odpowiedz 1", WS_CHILD | WS_VISIBLE | BS_CHECKBOX,
- 100, 100, 150, 30, hwnd, (HMENU)1, hInstance, NULL);
- hRadio2 = CreateWindowEx(0, "BUTTON", "Odpowiedz 2", WS_CHILD | WS_VISIBLE | BS_CHECKBOX,
- 100, 100, 150, 30, hwnd, (HMENU)2, hInstance, NULL);
- hRadio3 = CreateWindowEx(0, "BUTTON", "Odpowiedz 3", WS_CHILD | WS_VISIBLE | BS_CHECKBOX,
- 100, 100, 150, 30, hwnd, (HMENU)3, hInstance, NULL);
- hRadio4 = CreateWindowEx(0, "BUTTON", "Odpowiedz 1", WS_CHILD | WS_VISIBLE | BS_CHECKBOX,
- 100, 100, 150, 30, hwnd, (HMENU)4, hInstance, NULL);
- hRadio5 = CreateWindowEx(0, "BUTTON", "Odpowiedz 2", WS_CHILD | WS_VISIBLE | BS_CHECKBOX,
- 100, 100, 150, 30, hwnd, (HMENU)5, hInstance, NULL);
- hRadio6 = CreateWindowEx(0, "BUTTON", "Odpowiedz 3", WS_CHILD | WS_VISIBLE | BS_CHECKBOX,
- 100, 100, 150, 30, hwnd, (HMENU)6, hInstance, NULL);
- hRadio7 = CreateWindowEx(0, "BUTTON", "Odpowiedz 1", WS_CHILD | WS_VISIBLE | BS_CHECKBOX,
- 100, 100, 150, 30, hwnd, (HMENU)7, hInstance, NULL);
- hRadio8 = CreateWindowEx(0, "BUTTON", "Odpowiedz 2", WS_CHILD | WS_VISIBLE | BS_CHECKBOX,
- 100, 100, 150, 30, hwnd, (HMENU)8, hInstance, NULL);
- hRadio9 = CreateWindowEx(0, "BUTTON", "Odpowiedz 3", WS_CHILD | WS_VISIBLE | BS_CHECKBOX,
- 100, 100, 150, 30, hwnd, (HMENU)9, hInstance, NULL);
- hRadio10 = CreateWindowEx(0, "BUTTON", "Odpowiedz 1", WS_CHILD | WS_VISIBLE | BS_CHECKBOX,
- 100, 100, 150, 30, hwnd, (HMENU)10, hInstance, NULL);
- hRadio11 = CreateWindowEx(0, "BUTTON", "Odpowiedz 2", WS_CHILD | WS_VISIBLE | BS_CHECKBOX,
- 100, 100, 150, 30, hwnd, (HMENU)11, hInstance, NULL);
- hRadio12 = CreateWindowEx(0, "BUTTON", "Odpowiedz 3", WS_CHILD | WS_VISIBLE | BS_CHECKBOX,
- 100, 100, 150, 30, hwnd, (HMENU)12, hInstance, NULL);
- hButtonCheck = CreateWindowEx(0, "BUTTON", "Check", WS_CHILD | WS_VISIBLE,
- 100, 100, 150, 30, hwnd, NULL, hInstance, NULL);
- hPytanie1 = CreateWindowEx(0, "Static", "Odpowiedz 3", WS_CHILD | WS_VISIBLE | WS_BORDER, 50, 50, 150, 20,
- hwnd, NULL, hInstance, NULL);
- hPytanie2 = CreateWindowEx(0, "Static", "Odpwwiedz 2", WS_CHILD | WS_VISIBLE | WS_BORDER, 50, 50, 150, 20,
- hwnd, NULL, hInstance, NULL);
- hPytanie3 = CreateWindowEx(0, "Static", "Odpowiedz 1", WS_CHILD | WS_VISIBLE | WS_BORDER, 50, 50, 150, 20,
- hwnd, NULL, hInstance, NULL);
- hPytanie4 = CreateWindowEx(0, "Static", "Odpowiedz 3", WS_CHILD | WS_VISIBLE | WS_BORDER, 50, 50, 150, 20,
- hwnd, NULL, hInstance, NULL);
- wynik = CreateWindowEx(0, "Static",NULL, WS_CHILD | WS_VISIBLE | WS_BORDER, 50, 50, 150, 20,
- hwnd, NULL, hInstance, NULL);
- if (hwnd == NULL)
- {
- MessageBox(NULL, TEXT("Okno odmówiło przyjścia na świat!"), TEXT("Ale kicha..."), MB_ICONEXCLAMATION);
- return 1;
- }
- ShowWindow(hwnd, nCmdShow);
- UpdateWindow(hwnd);
- while (GetMessage(&Komunikat, NULL, 0, 0))
- {
- TranslateMessage(&Komunikat);
- DispatchMessage(&Komunikat);
- }
- return Komunikat.wParam;
- }
- LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- switch (msg)
- {
- case WM_COMMAND:
- if ((HWND)lParam == hRadio1)
- {
- CheckRadioButton(hwnd, 1, 3, 1);
- }
- if ((HWND)lParam == hRadio2)
- {
- CheckRadioButton(hwnd, 1, 3, 2);
- }
- if ((HWND)lParam == hRadio3)
- {
- CheckRadioButton(hwnd, 1, 3, 3);
- }
- if ((HWND)lParam == hRadio4)
- {
- CheckRadioButton(hwnd, 4, 6, 4);
- }
- if ((HWND)lParam == hRadio5)
- {
- CheckRadioButton(hwnd, 4, 6, 5);
- }
- if ((HWND)lParam == hRadio6)
- {
- CheckRadioButton(hwnd, 4, 6, 6);
- }
- if ((HWND)lParam == hRadio7)
- {
- CheckRadioButton(hwnd, 7, 9, 7);
- }
- if ((HWND)lParam == hRadio8)
- {
- CheckRadioButton(hwnd, 7, 9, 8);
- }
- if ((HWND)lParam == hRadio9)
- {
- CheckRadioButton(hwnd, 7, 9, 9);
- }
- if ((HWND)lParam == hRadio10)
- {
- CheckRadioButton(hwnd, 10, 12, 10);
- }
- if ((HWND)lParam == hRadio11)
- {
- CheckRadioButton(hwnd, 10, 12, 11);
- }
- if ((HWND)lParam == hRadio12)
- {
- CheckRadioButton(hwnd, 10, 12, 12);
- }
- if ((HWND)lParam == hButtonCheck)
- {
- if ((IsDlgButtonChecked(hwnd, 3) == BST_CHECKED) == 1) wynik1 = 1; else wynik1 = 0;
- if ((IsDlgButtonChecked(hwnd, 5) == BST_CHECKED) == 1) wynik2 = 1; else wynik2 = 0;
- if ((IsDlgButtonChecked(hwnd, 7) == BST_CHECKED) == 1) wynik3 = 1; else wynik3 = 0;
- if ((IsDlgButtonChecked(hwnd, 12) == BST_CHECKED) == 1) wynik4 = 1; else wynik4 = 0;
- if (wynik1 == 1) wsprintf(w1, "%s", "Odpowiedziales dobrze na pytanie 1"); else wsprintf(w1, "%s", "Odpowiedziales zle na pytanie 1");
- if (wynik2 == 1) wsprintf(w2, "%s", "Odpowiedziales dobrze na pytanie 2"); else wsprintf(w2, "%s", "Odpowiedziales zle na pytanie 2");
- if (wynik3 == 1) wsprintf(w3, "%s", "Odpowiedziales dobrze na pytanie 3"); else wsprintf(w3, "%s", "Odpowiedziales zle na pytanie 3");
- if (wynik4 == 1) wsprintf(w4, "%s", "Odpowiedziales dobrze na pytanie 4"); else wsprintf(w4, "%s", "Odpowiedziales zle na pytanie 4");
- wsprintf(gotowy, "%s\n%s\n%s\n%s",w1,w2,w3,w4);
- SetWindowText(wynik, gotowy);
- }
- break;
- case WM_CREATE:
- break;
- case WM_CLOSE:
- DestroyWindow(hwnd);
- break;
- case WM_DESTROY:
- PostQuitMessage(0);
- break;
- case WM_SIZE:
- GetClientRect(hwnd, &Rect);
- MoveWindow(hPytanie1, Rect.right / 2 - 75, 0, 150, 20, TRUE);
- MoveWindow(hRadio1, Rect.right / 2 - 75, 20, 150, 20, TRUE);
- MoveWindow(hRadio2, Rect.right / 2 - 75, 40, 150, 20, TRUE);
- MoveWindow(hRadio3, Rect.right / 2 - 75, 60, 150, 20, TRUE);
- MoveWindow(hPytanie2, Rect.right / 2 - 75, 80, 150, 20, TRUE);
- MoveWindow(hRadio4, Rect.right / 2 - 75, 100, 150, 20, TRUE);
- MoveWindow(hRadio5, Rect.right / 2 - 75, 120, 150, 20, TRUE);
- MoveWindow(hRadio6, Rect.right / 2 - 75, 140, 150, 20, TRUE);
- MoveWindow(hPytanie3, Rect.right / 2 - 75, 160, 150, 20, TRUE);
- MoveWindow(hRadio7, Rect.right / 2 - 75, 180, 150, 20, TRUE);
- MoveWindow(hRadio8, Rect.right / 2 - 75, 200, 150, 20, TRUE);
- MoveWindow(hRadio9, Rect.right / 2 - 75, 220, 150, 20, TRUE);
- MoveWindow(hPytanie4, Rect.right / 2 - 75, 240, 150, 20, TRUE);
- MoveWindow(hRadio10, Rect.right / 2 - 75, 260, 150, 20, TRUE);
- MoveWindow(hRadio11, Rect.right / 2 - 75, 280, 150, 20, TRUE);
- MoveWindow(hRadio12, Rect.right / 2 - 75, 300, 150, 20, TRUE);
- MoveWindow(hButtonCheck, Rect.right / 2 - 75, 320, 50, 20, TRUE);
- MoveWindow(wynik, Rect.right / 2 - 75, 340, 150, 150, TRUE);
- break;
- default:
- return DefWindowProc(hwnd, msg, wParam, lParam);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement