Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- #include <string>
- #include <vector>
- #include "resource.h"
- using namespace std;
- struct school {
- string Name, Semestr, Class, ECTS ,Description;
- bool Finals;
- }SchoolBuff;
- vector <school> School;
- PAINTSTRUCT PS;
- HDC hdc;
- RECT WndRect;
- int CALLBACK AddProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
- switch (msg) {
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case IDOK: {
- char TextBuff[255];
- GetWindowText(GetDlgItem(hwnd, ID_DIALOG_NAME), TextBuff, 255);
- SchoolBuff.Name = string(TextBuff);
- GetWindowText(GetDlgItem(hwnd, ID_DIALOG_SEMESTR), TextBuff, 255);
- SchoolBuff.Semestr = string(TextBuff);
- GetWindowText(GetDlgItem(hwnd, ID_DIALOG_ECTS), TextBuff, 255);
- SchoolBuff.ECTS = string(TextBuff);
- GetWindowText(GetDlgItem(hwnd, ID_DIALOG_DESC), TextBuff, 255);
- SchoolBuff.Description = string(TextBuff);
- if (IsDlgButtonChecked(hwnd, IDR_EG) == BST_CHECKED)
- SchoolBuff.Finals = true;
- else
- SchoolBuff.Finals = false;
- if (IsDlgButtonChecked(hwnd, IDR_INF) == BST_CHECKED) {
- SchoolBuff.Class = "Informatyka";
- }
- if (IsDlgButtonChecked(hwnd, IDR_ELETECH) == BST_CHECKED) {
- SchoolBuff.Class = "Elektrotechnika";
- }
- if (IsDlgButtonChecked(hwnd, IDR_ELE) == BST_CHECKED) {
- SchoolBuff.Class = "Elektronika";
- }
- if (IsDlgButtonChecked(hwnd, IDR_MECH) == BST_CHECKED) {
- SchoolBuff.Class = "Mechatronika";
- }
- if (IsDlgButtonChecked(hwnd, IDR_ENE) == BST_CHECKED) {
- SchoolBuff.Class = "Energetyka";
- }
- // TODO: Zabezpieczenia
- School.push_back(SchoolBuff);
- EndDialog(hwnd, 1);
- }break;
- }
- break;
- case WM_INITDIALOG: break;
- case WM_CLOSE: EndDialog(hwnd, 1); break;
- default: return 0;
- }
- return 1;
- }
- HWND Static;
- LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
- switch (msg) {
- case WM_PAINT: {
- hdc = BeginPaint(hwnd, &PS);
- string s = "";
- for (int i = 0; i < School.size(); i++) {
- 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;
- TextOut(hdc, 30, 100 * (i+1), s.c_str(), s.length());
- //Static = CreateWindowEx(0, "STATIC", s.c_str(), WS_CHILD | WS_VISIBLE, 10, 65, 750, 50, hwnd, 0, 0, 0);
- }
- EndPaint(hwnd, &PS);
- }break;
- case WM_TIMER:
- GetClientRect(hwnd, &WndRect);
- InvalidateRect(hwnd, &WndRect, 1);
- break;
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case IDA_ADD_NEW:
- case ID_WPIS_DODAJ:
- DialogBox(0, MAKEINTRESOURCE(IDD_DIALOG_ADD), hwnd, AddProc);
- break;
- case IDA_ADD_ERASE:
- case ID_WPIS_USUN:
- School.clear();
- break;
- case IDA_ADD_CLOSE:
- case ID_WPIS_KONIEC:
- PostQuitMessage(0);
- break;
- }
- break;
- case WM_CLOSE: DestroyWindow(hwnd); break;
- case WM_DESTROY: PostQuitMessage(0); break;
- default: return DefWindowProc(hwnd, msg, wParam, lParam);
- }
- return 0;
- }
- int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR ilCmdLine, int nCmdShow) {
- WNDCLASSEX window;
- MSG msg;
- TCHAR Class_Name[] = TEXT("OKNO_TEST"), Title[] = TEXT("Tytul");
- window.cbClsExtra = NULL;
- window.cbSize = sizeof(WNDCLASSEX);
- window.cbWndExtra = NULL;
- window.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
- window.hCursor = LoadCursor(NULL, IDC_ARROW);
- window.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- window.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
- window.hInstance = hInstance;
- window.lpfnWndProc = WndProc;
- window.lpszClassName = Class_Name;
- window.lpszMenuName = MAKEINTRESOURCE(IDM_MAIN_MAIN_TOP);
- window.style = CS_VREDRAW | CS_HREDRAW;
- RegisterClassEx(&window);
- HACCEL Acc = LoadAccelerators(hInstance, MAKEINTRESOURCE(ID_ACCELERATORS));
- HWND hwnd = CreateWindowEx(WS_EX_WINDOWEDGE, Class_Name, Title, WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, NULL, NULL, hInstance, NULL);
- SetTimer(hwnd, 0, 200, 0);
- 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);
- ShowWindow(hwnd, nCmdShow);
- UpdateWindow(hwnd);
- while (GetMessage(&msg, NULL, 0, 0)) {
- if (!TranslateAccelerator(hwnd, Acc, &msg)) {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- }
- UnregisterClass(Class_Name, hInstance);
- return msg.wParam;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement