Робота з файловою системою.

Інформація про навчальний заклад

ВУЗ:
Національний університет Львівська політехніка
Інститут:
Не вказано
Факультет:
КН
Кафедра:
Кафедра електронних обчислювальних машин

Інформація про роботу

Рік:
2013
Тип роботи:
Звіт про виконання лабораторної роботи
Предмет:
Об’єктно-орієнтоване програмування

Частина тексту файла (без зображень, графіків і формул):

Міністерство освіти і науки України Національний університет „Львівська політехніка” Кафедра електронних обчислювальних машин Звіт про виконання лабораторної роботи № 5 з курсу „ Об'єктно-орієнтоване програмування ” Тема: Робота з файловою системою. Львів – 2004 Мета роботи: Навчитись створювати віконні програми, оволодіти практичними навичками створення графічного інтерфейсу користувача, ознайомитись із класами MFC для роботи з файловою системою Windows. Завдання на лабораторну роботу  Створити віконну програму, яка б відтворювала модель цифрового пристрою: Пристрою пошуку максимуму сигналу. Пристрій повинен видати значення максимуму та відлік у якому він досягається. Вміст файлів // lab5Dlg.h : header file // #if !defined(AFX_LAB5DLG_H__BE3F3A35_AC8B_43F9_9A48_08EE414E7337__INCLUDED_) #define AFX_LAB5DLG_H__BE3F3A35_AC8B_43F9_9A48_08EE414E7337__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 ///////////////////////////////////////////////////////////////////////////// // CLab5Dlg dialog class CLab5Dlg : public CDialog { public: unsigned int buf; char * str; CLab5Dlg(CWnd* pParent = NULL); // standard constructor //{{AFX_DATA(CLab5Dlg) enum { IDD = IDD_LAB5_DIALOG }; CEdit m_Ed2; CEdit m_Ed1; CString m_Num1; CString m_Num2; //}}AFX_DATA //{{AFX_VIRTUAL(CLab5Dlg) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL protected: HICON m_hIcon; //{{AFX_MSG(CLab5Dlg) virtual BOOL OnInitDialog(); afx_msg void OnPaint(); afx_msg HCURSOR OnQueryDragIcon(); afx_msg void OnButton1(); afx_msg void OnButton2(); afx_msg void OnButton3(); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; //{{AFX_INSERT_LOCATION}} #endif // !defined(AFX_LAB5DLG_H__BE3F3A35_AC8B_43F9_9A48_08EE414E7337__INCLUDED_) // lab5Dlg.cpp : implementation file // #include "stdafx.h" #include "lab5.h" #include "lab5Dlg.h" #include "sumator.h" #include "stdio.h" #include "stdlib.h" #include "const.h" #include "signal.h" #include "conio.h" #include "fstream.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CLab5Dlg dialog CLab5Dlg::CLab5Dlg(CWnd* pParent /*=NULL*/) : CDialog(CLab5Dlg::IDD, pParent) { //{{AFX_DATA_INIT(CLab5Dlg) m_Num1 = _T(""); m_Num2 = _T(""); //}}AFX_DATA_INIT m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void CLab5Dlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CLab5Dlg) DDX_Control(pDX, IDC_EDIT2, m_Ed2); DDX_Control(pDX, IDC_EDIT1, m_Ed1); DDX_Text(pDX, IDC_EDIT1, m_Num1); DDX_Text(pDX, IDC_EDIT2, m_Num2); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CLab5Dlg, CDialog) //{{AFX_MSG_MAP(CLab5Dlg) ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_BN_CLICKED(IDC_BUTTON1, OnButton1) ON_BN_CLICKED(IDC_BUTTON2, OnButton2) ON_BN_CLICKED(IDC_BUTTON3, OnButton3) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CLab5Dlg message handlers BOOL CLab5Dlg::OnInitDialog() { CDialog::OnInitDialog(); SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon return TRUE; // return TRUE unless you set the focus to a control } void CLab5Dlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; dc.DrawIcon(x, y, m_hIcon); } else { CDialog::OnPaint(); } } HCURSOR CLab5Dlg::OnQueryDragIcon() { return (HCURSOR) m_hIcon; } void CLab5Dlg::OnButton1() { CFile file1; CFileDialog fileDlg(true); int nResponse = fileDlg.DoModal(); if (nResponse ==IDOK) {file1.Open(fileDlg.GetPathName(), CFile::modeRead); char* str = new char[file1.GetLength()-4]; file1.Read(str, file1.GetLength()); SetDlgItemText(IDC_EDIT1, str); } } void CLab5Dlg::OnButton2() { CFile file1; CFileDialog fileDlg(true); int nResponse = fileDlg.DoModal(); if (nResponse ==IDOK) {file1.Open(fileDlg.GetPathName(), CFile::modeRead); str = new char[file1.GetLength()-4]; file1.Read(str, file1.GetLength()); SetDlgItemText(IDC_EDIT2, str); } } void CLab5Dlg::OnButton3() { int x,y,i; char buf[600]; char *news; char next[600]; m_Ed1.GetWindowText(buf,10); x=atoi(buf); m_Ed2.GetWindowText(buf,10); y=atoi(buf); y=y+x; itoa (y, next, 10); news=strcat(next, "\n"); news=strcat(next, "ttt"); SetDlgItemText (IDC_EDIT3,news); } // const.h const int n=32; // DigitalDevice.h: interface for the CDigitalDevice class. #if !defined(AFX_DIGITALDEVICE_H__D764ED80_07A8_4DF1_A07F_BA2A931F3724__INCLUDED_) #define AFX_DIGITALDEVICE_H__D764ED80_07A8_4DF1_A07F_BA2A931F3724__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 class CDigitalDevice { public: unsigned int Function (unsigned int, unsigned int); unsigned int Output (unsigned int); unsigned int Input (unsigned int); unsigned int Out1; unsigned int In1; unsigned int In2; unsigned int Out2; CDigitalDevice(); virtual ~CDigitalDevice(); }; #endif // !defined(AFX_DIGITALDEVICE_H__D764ED80_07A8_4DF1_A07F_BA2A931F3724__INCLUDED_) // DigitalDevice.cpp: implementation of the CDigitalDevice class. // #include "stdafx.h" #include "lab5.h" #include "lab5Dlg.h" #include "DigitalDevice.h" #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif CDigitalDevice::CDigitalDevice(){} CDigitalDevice::~CDigitalDevice(){} unsigned int CDigitalDevice::Input (unsigned int InPut) { return InPut; } unsigned int CDigitalDevice::Output (unsigned int Signal) { return Signal; } unsigned int CDigitalDevice::Function (unsigned int, unsigned int) { return 0; } // Signal.h: interface for the CSignal class. // #if !defined(AFX_SIGNAL_H__EA6C8C6D_2CB9_4248_BC4E_31C9A4EA59E6__INCLUDED_) #define AFX_SIGNAL_H__EA6C8C6D_2CB9_4248_BC4E_31C9A4EA59E6__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 class CSignal { public: unsigned int Signal; typedef unsigned int SignalT; CSignal(); virtual ~CSignal(); } #endif // !defined(AFX_SIGNAL_H__EA6C8C6D_2CB9_4248_BC4E_31C9A4EA59E6__INCLUDED_) // Signal.cpp: implementation of the CSignal class. // #include "stdafx.h" #include "lab5.h" #include "lab5Dlg.h" #include "Signal.h" CSignal::CSignal(){} CSignal::~CSignal(){} // Sumator.h: interface for the CSumator class. // #if !defined(AFX_SUMATOR_H__99232120_5C28_4B13_87E0_F8F292EF8A1A__INCLUDED_) #define AFX_SUMATOR_H__99232120_5C28_4B13_87E0_F8F292EF8A1A__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "DigitalDevice.h" class CSumator : public CDigitalDevice { public: unsigned int Carry (unsigned int, unsigned int, unsigned int); unsigned int CarryIn; unsigned int CarrySum (unsigned int, unsigned int, unsigned int); unsigned int CarryOut; int SelectIn; unsigned int Function (unsigned int, unsigned int); CSumator(); virtual ~CSumator(); }; #endif // !defined(AFX_SUMATOR_H__99232120_5C28_4B13_87E0_F8F292EF8A1A__INCLUDED_) // Sumator.cpp: implementation of the CSumator class. // #include "stdafx.h" #include "lab5.h" #include "lab5Dlg.h" #include "Sumator.h" #include "const.h" CSumator::CSumator(){} CSumator::~CSumator(){} unsigned int CSumator::CarrySum(unsigned int a, unsigned int b, unsigned int CF) { unsigned int S; S=(~a)&(~b)&(CF) | (~a)&b&(~CF) | a&(~b)&(~CF) | a&b&CF; return S; } unsigned int CSumator::Function (unsigned int a, unsigned int b) { int S; S= (a|b) & ~(a&b); return S; } unsigned int CSumator::Carry(unsigned int a, unsigned int b, unsigned int CF) { unsigned int CFlag; if ((a+b+CF)>=2147483646) CFlag=1; else CFlag=0; return CFlag; } //{{NO_DEPENDENCIES}} #define IDD_LAB5_DIALOG 102 #define IDR_MAINFRAME 128 #define IDC_EDIT1 1000 #define IDC_BUTTON1 1001 #define IDC_EDIT2 1003 #define IDC_BUTTON2 1004 #define IDC_BUTTON3 1005 #define IDC_CHECK1 1006 #define IDC_EDIT3 1007 #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 132 #define _APS_NEXT_COMMAND_VALUE 32771 #define _APS_NEXT_CONTROL_VALUE 1008 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif Вигляд програми  Висновок: Виконуючи дану лабораторну роботу, я навчився створювати віконні програми та працювати з класами MFC для роботи з файловою системою Windows, оволодів практичними навичками створення графічного інтерфейсу користувача та прикладного програмування.
Антиботан аватар за замовчуванням

31.03.2013 13:35

Коментарі

Ви не можете залишити коментар. Для цього, будь ласка, увійдіть або зареєструйтесь.

Ділись своїми роботами та отримуй миттєві бонуси!

Нічого не вибрано
0%

Оголошення від адміністратора

Антиботан аватар за замовчуванням

Подякувати Студентському архіву довільною сумою

Admin

26.02.2023 12:38

Дякуємо, що користуєтесь нашим архівом!