Advertisement
Alan468

Lista przedmiotów i ECTS

Dec 13th, 2016
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Windows.h>
  2. #include <string>
  3. #include <vector>
  4. #include "resource.h"
  5.  
  6. using namespace std;
  7.  
  8. struct school {
  9.     string Name, Semestr, Class, ECTS ,Description;
  10.     bool Finals;
  11. }SchoolBuff;
  12.  
  13. vector <school> School;
  14. PAINTSTRUCT PS;
  15. HDC hdc;
  16. RECT WndRect;
  17.  
  18. int CALLBACK AddProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
  19.     switch (msg) {
  20.     case WM_COMMAND:
  21.         switch (LOWORD(wParam)) {
  22.         case IDOK: {
  23.             char TextBuff[255];
  24.  
  25.             GetWindowText(GetDlgItem(hwnd, ID_DIALOG_NAME), TextBuff, 255);
  26.             SchoolBuff.Name = string(TextBuff);
  27.  
  28.             GetWindowText(GetDlgItem(hwnd, ID_DIALOG_SEMESTR), TextBuff, 255);
  29.             SchoolBuff.Semestr = string(TextBuff);
  30.  
  31.             GetWindowText(GetDlgItem(hwnd, ID_DIALOG_ECTS), TextBuff, 255);
  32.             SchoolBuff.ECTS = string(TextBuff);
  33.  
  34.             GetWindowText(GetDlgItem(hwnd, ID_DIALOG_DESC), TextBuff, 255);
  35.             SchoolBuff.Description = string(TextBuff);
  36.  
  37.             if (IsDlgButtonChecked(hwnd, IDR_EG) == BST_CHECKED)
  38.                 SchoolBuff.Finals = true;
  39.             else
  40.                 SchoolBuff.Finals = false;
  41.  
  42.             if (IsDlgButtonChecked(hwnd, IDR_INF) == BST_CHECKED) {
  43.                 SchoolBuff.Class = "Informatyka";
  44.             }
  45.             if (IsDlgButtonChecked(hwnd, IDR_ELETECH) == BST_CHECKED) {
  46.                 SchoolBuff.Class = "Elektrotechnika";
  47.             }
  48.             if (IsDlgButtonChecked(hwnd, IDR_ELE) == BST_CHECKED) {
  49.                 SchoolBuff.Class = "Elektronika";
  50.             }
  51.             if (IsDlgButtonChecked(hwnd, IDR_MECH) == BST_CHECKED) {
  52.                 SchoolBuff.Class = "Mechatronika";
  53.             }
  54.             if (IsDlgButtonChecked(hwnd, IDR_ENE) == BST_CHECKED) {
  55.                 SchoolBuff.Class = "Energetyka";
  56.             }
  57.             // TODO: Zabezpieczenia
  58.             School.push_back(SchoolBuff);
  59.             EndDialog(hwnd, 1);
  60.         }break;
  61.         }
  62.         break;
  63.     case WM_INITDIALOG: break;
  64.     case WM_CLOSE: EndDialog(hwnd, 1); break;
  65.     default: return 0;
  66.     }
  67.     return 1;
  68. }
  69.  
  70. HWND Static;
  71.  
  72. LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
  73.     switch (msg) {
  74.     case WM_PAINT: {
  75.         hdc = BeginPaint(hwnd, &PS);
  76.  
  77.         string s = "";
  78.  
  79.         for (int i = 0; i < School.size(); i++) {
  80.             s = School[i].Name + " \t\t " + School[i].Semestr + " \t\t " + School[i].Class + " \t\t " + School[i].ECTS + " \t\t " + (School[i].Finals?"TAK":"NIE") + " \t\t " + School[i].Description;
  81.             TextOut(hdc, 30, 100 * (i+1), s.c_str(), s.length());
  82.             //Static = CreateWindowEx(0, "STATIC", s.c_str(), WS_CHILD | WS_VISIBLE, 10, 65, 750, 50, hwnd, 0, 0, 0);
  83.         }
  84.  
  85.         EndPaint(hwnd, &PS);
  86.     }break;
  87.     case WM_TIMER:
  88.         GetClientRect(hwnd, &WndRect);
  89.         InvalidateRect(hwnd, &WndRect, 1);
  90.         break;
  91.     case WM_COMMAND:
  92.         switch (LOWORD(wParam)) {
  93.         case IDA_ADD_NEW:
  94.         case ID_WPIS_DODAJ:
  95.             DialogBox(0, MAKEINTRESOURCE(IDD_DIALOG_ADD), hwnd, AddProc);
  96.             break;
  97.         case IDA_ADD_ERASE:
  98.         case ID_WPIS_USUN:
  99.             School.clear();
  100.             break;
  101.         case IDA_ADD_CLOSE:
  102.         case ID_WPIS_KONIEC:
  103.             PostQuitMessage(0);
  104.             break;
  105.         }
  106.         break;
  107.     case WM_CLOSE: DestroyWindow(hwnd); break;
  108.     case WM_DESTROY: PostQuitMessage(0); break;
  109.     default: return DefWindowProc(hwnd, msg, wParam, lParam);
  110.     }
  111.     return 0;
  112. }
  113.  
  114. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR ilCmdLine, int nCmdShow) {
  115.     WNDCLASSEX window;
  116.     MSG msg;
  117.     TCHAR Class_Name[] = TEXT("OKNO_TEST"), Title[] = TEXT("Tytul");
  118.  
  119.     window.cbClsExtra = NULL;
  120.     window.cbSize = sizeof(WNDCLASSEX);
  121.     window.cbWndExtra = NULL;
  122.     window.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
  123.     window.hCursor = LoadCursor(NULL, IDC_ARROW);
  124.     window.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  125.     window.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
  126.     window.hInstance = hInstance;
  127.     window.lpfnWndProc = WndProc;
  128.     window.lpszClassName = Class_Name;
  129.     window.lpszMenuName = MAKEINTRESOURCE(IDM_MAIN_MAIN_TOP);
  130.     window.style = CS_VREDRAW | CS_HREDRAW;
  131.  
  132.     RegisterClassEx(&window);
  133.  
  134.     HACCEL Acc = LoadAccelerators(hInstance, MAKEINTRESOURCE(ID_ACCELERATORS));
  135.  
  136.     HWND hwnd = CreateWindowEx(WS_EX_WINDOWEDGE, Class_Name, Title, WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, NULL, NULL, hInstance, NULL);
  137.    
  138.     SetTimer(hwnd, 0, 200, 0);
  139.  
  140.     Static = CreateWindowEx(0, "STATIC", "Nazwa \t\t Semestr \t\t Kierunek \t\t ECTS \t\t Egzamin \t Opis \t", WS_CHILD | WS_VISIBLE, 10, 10, 750, 50, hwnd, 0, 0, 0);
  141.  
  142.     ShowWindow(hwnd, nCmdShow);
  143.     UpdateWindow(hwnd);
  144.  
  145.     while (GetMessage(&msg, NULL, 0, 0)) {
  146.         if (!TranslateAccelerator(hwnd, Acc, &msg)) {
  147.             TranslateMessage(&msg);
  148.             DispatchMessage(&msg);
  149.         }
  150.     }
  151.  
  152.     UnregisterClass(Class_Name, hInstance);
  153.  
  154.     return msg.wParam;
  155. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement