bsuir.info
БГУИР: Дистанционное и заочное обучение
(файловый архив)
Вход (быстрый)
Регистрация
Категории каталога
Другое [236]
Форма входа
Логин:
Пароль:
Поиск
Статистика

Онлайн всего: 1
Гостей: 1
Пользователей: 0
Файловый архив
Файлы » ИТиУвТС » Другое

Кр по ТРПО 14 вар
Подробности о скачивании 16.11.2011, 15:46
Лабораторная работа №1. Мастера Сlassview и Сlasswizard в Visual C++ 6.0

Задание
14. .

Решение:
// x.cpp: implementation of the x class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "zadacha_1.h"
#include "x.h"
#include "math.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
x::x()
{}
x::~x()
{
}
/* обьявление методов */
void x::run() // метод для вычесления значений z1 и z2
{
z1=((m+2)/sqrt(2*m)+2/(m-sqrt(2*m))-m/(sqrt(2*m)+2))*(sqrt(m)-sqrt(2))/(m+2);
z2=1/(sqrt(m)+sqrt(2));
}
void x::print() // метод для вывода результатов
{
CString str;
/* объявили строковый объект класса библиотеки MFC, и при помощи его вызвали метод,
который работает как стандартная функция printf(…), но выводит значения объектов из
списка вывода в указанную строку*/
str.Format("Для m=%10.5f \n z1=%10.5f, z2=%10.5f",m, z1, z2);
AfxMessageBox(str);
}
void x::set(double a1) // метод для инициализации класса
{m=a1;
AfxMessageBox("Объект создан и проинициализирован!");
}

// zadacha_1Dlg.cpp : implementation file
#include "stdafx.h"
#include "zadacha_1.h"
#include "zadacha_1Dlg.h"
#include "x.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CZadacha_1Dlg dialog
CZadacha_1Dlg::CZadacha_1Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CZadacha_1Dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CZadacha_1Dlg)
m_m = 0.0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CZadacha_1Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CZadacha_1Dlg)
DDX_Text(pDX, IDC_EDIT1, m_m);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CZadacha_1Dlg, CDialog)
//{{AFX_MSG_MAP(CZadacha_1Dlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CZadacha_1Dlg message handlers
BOOL CZadacha_1Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CZadacha_1Dlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
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;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CZadacha_1Dlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CZadacha_1Dlg::OnButton1()
{
UpdateData(TRUE); // данные считываються из элементов управления диалогового окна
//и обновляються переменные оконного объекта
x x1; // Конструктор класса x создает объект x1
x1.set(m_m); // инициализация данных
x1.run(); // вычисление
x1.print(); // вывод
UpdateData(FALSE); // обновляет содержимое элементов управления диалогового окна
}







Лабораторная работа №4. Работа с элементом управления «Окно списка» (ListBox)

Задание
14.

Решение:
// lab4Dlg.cpp : implementation file
//

#include "stdafx.h"
#include "lab4.h"
#include "lab4Dlg.h"
#include "math.h"
#define pi 3.1415926535897932384626433832795

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CLab4Dlg dialog

CLab4Dlg::CLab4Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CLab4Dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CLab4Dlg)
m_x1 = 0.0;
m_x2 = 0.0;
m_h = 0.0;
m_n = 0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CLab4Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CLab4Dlg)
DDX_Control(pDX, IDC_LIST1, m_l);
DDX_Text(pDX, IDC_EDIT1, m_x1);
DDV_MinMaxDouble(pDX, m_x1, 0.1, 0.3);
DDX_Text(pDX, IDC_EDIT2, m_x2);
DDV_MinMaxDouble(pDX, m_x2, 0.7, 0.9);
DDX_Text(pDX, IDC_EDIT3, m_h);
DDV_MinMaxDouble(pDX, m_h, 0.1, 0.2);
DDX_Text(pDX, IDC_EDIT4, m_n);
DDV_MinMaxInt(pDX, m_n, 5, 20);
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CLab4Dlg, CDialog)
//{{AFX_MSG_MAP(CLab4Dlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CLab4Dlg message handlers

BOOL CLab4Dlg::OnInitDialog()
{
CDialog::OnInitDialog();

// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon

// TODO: Add extra initialization here

return TRUE; // return TRUE unless you set the focus to a control
}

// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.

void CLab4Dlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting

SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

// Center icon in client rectangle
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;

// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}

// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CLab4Dlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}

int i;
double x,s,y;
CString str;
void CLab4Dlg::OnButton1()
{
// TODO: Add your control notification handler code here
UpdateData(true);
str.Format(" x1=%.3lf, x2=%.3lf, h=%.3lf, n=%3d ", m_x1, m_x2, m_h, m_n);
m_l.AddString(str);
UpdateData(false);
for (x=m_x1;x<=m_x2;x=x+m_h)
{
s=0;
for(i=1;i<=m_n;i++)
{
s+=pow(-1,i)*cos(i*x)/(i*i);
}
y=(x*x-pi*pi/3)/4;
str.Format("Для x= %.3lf, сумма= %.3lf, y= %.3lf", x,s,y);
m_l.AddString(str);
UpdateData(FALSE);
}
}
void CLab4Dlg::OnButton2()
{
// TODO: Add your control notification handler code here
m_l.ResetContent();
}





Лабораторная работа №6. Элементы управления «Шкала индикации» (Progress) и «Маркер» (Slider). Модальные диалоговые окна

Задание
14.

Решение
// CLabProgressBarDlg.cpp : implementation file
//
#include "stdafx.h"
#include "CLabProgressBar.h"
#include "CLabProgressBarDlg.h"
#include "math.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCLabProgressBarDlg dialog

CCLabProgressBarDlg::CCLabProgressBarDlg(CWnd* pParent /*=NULL*/)
: CDialog(CCLabProgressBarDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CCLabProgressBarDlg)
m_res = 0.0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CCLabProgressBarDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCLabProgressBarDlg)
DDX_Control(pDX, IDC_SLIDER1, m_slider);
DDX_Control(pDX, IDC_PROGRESS1, m_progress);
DDX_Text(pDX, IDC_EDIT1, m_res);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCLabProgressBarDlg, CDialog)
//{{AFX_MSG_MAP(CCLabProgressBarDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCLabProgressBarDlg message handlers
BOOL CCLabProgressBarDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
// TODO: Add extra initialization here
m_slider.SetRange(100,1000000);
// устанавливаем диапазон в элементе Slider
m_slider.SetPos(50000);
//устанавливаем положение ползунка
//return TRUE; // return TRUE unless you set the focus to a control
//}

return TRUE; // return TRUE unless you set the focus to a control
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CCLabProgressBarDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
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;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CCLabProgressBarDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CCLabProgressBarDlg::OnButton1()
{
// TODO: Add your control notification handler code here
//обработчик кнопки Граничные условия.
d.DoModal(); //вызов модального окна
}
void CCLabProgressBarDlg::OnButton2()
{ //обработчик кнопки Пуск.
CWaitCursor w; //класс для установки курсора - часы.
double s=0;
double x=d.m_a; //считывание из диалога нач. значения.
double h=(d.m_b-x)/m_slider.GetPos(); //вычисление h=(b-a)/N
int i=0;
while(x<d.m_b)
{ double f=cos(2*x); //числение квадрата икса
s+=f*h; // вычисление суммы
x+=h;
m_progress.SetPos(100*i++/m_slider.GetPos());
//установка положения в полосы в Progress
}m_res=s;
UpdateData(0);
}





Лабораторная работа №7. SDI – приложение. Работа с данными в архитектуре «Документ/представление» («Document/view»)

Задание
Создать SDI-приложение для формирования и просмотра данных из файла в соответствии с индивидуальным заданием.
Требования для создаваемого приложения.
1. Управление заданием имени файла, его открытием или созданием и т.п. выполняется через команды меню или кнопки панели инструментов.
2. Просмотр загруженных данных из файла, а также формируемых в приложении, данных выполняется в диалоговом окне с использованием элемента управления Listbox. В этом списке отображается либо все данные, либо данные, формируемые в соответствии с функцией, определенной в индивидуальном задании. Порядок вывода управляется с помощью кнопок. Исходно выводится полный список.
3. Формирование данных в приложении осуществляется в другом диалоговом окне с использованием элементов управления Combobox и Edit.
4. До задания имени файла элементы меню и соответствующие кнопки управления открытием и сохранением данных в файл должны быть не доступны.
5. После задания имени файла все команды работы с файлом должны иметь место только для этого файла.
6. Имя заданного файла должно отображаться в строке статуса.
Индивидуальные задание
14. Продовольственные товары (наименование, отдел магазина, дата выпуска, срок хранения, последний срок реализации – функция Run (), вес).

Решение:
// MDIDoc.cpp : implementation of the CMDIDoc class
//

#include "stdafx.h"
#include "MDI.h"

#include "MDIDoc.h"
#include "MyDialog.h"
#include "MyDialog2.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMDIDoc

IMPLEMENT_DYNCREATE(CMDIDoc, CDocument)

BEGIN_MESSAGE_MAP(CMDIDoc, CDocument)
//{{AFX_MSG_MAP(CMDIDoc)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMDIDoc construction/destruction

CMDIDoc::CMDIDoc()
{
// TODO: add one-time construction code here

}

CMDIDoc::~CMDIDoc()
{
}

CMDIDoc* CMDIDoc::GetDoc()
{
CMDIChildWnd * pChild =
((CMDIFrameWnd*)(AfxGetApp()->m_pMainWnd))->MDIGetActive();

if ( !pChild )
return NULL;

CDocument * pDoc = pChild->GetActiveDocument();

if ( !pDoc )
return NULL;

// Ошибка, если документ неправильного типа
if ( ! pDoc->IsKindOf( RUNTIME_CLASS(CMDIDoc) ) )
return NULL;

return (CMDIDoc *) pDoc;
}

BOOL CMDIDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;

m_data.SetSize(1, 1);
return TRUE;
}

/////////////////////////////////////////////////////////////////////////////
// CMDIDoc serialization

void CMDIDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
ar << m_data.GetSize();
for (int i=0; i < m_data.GetSize(); i++)
{
ar << m_data.GetAt(i).naim;
ar << m_data.GetAt(i).otd;
ar << m_data.GetAt(i).dt4;
ar << m_data.GetAt(i).dtm;
ar << m_data.GetAt(i).dtg;
ar << m_data.GetAt(i).srd;
ar << m_data.GetAt(i).srm;
ar << m_data.GetAt(i).srg;

}
}
else
{
int size;
STRUCTRECORD rec;
ar >> size;
m_data.SetSize(size, 1);
for (int i=0; i < size; i++)
{
ar >> rec.naim;
ar >> rec.otd;
ar >> rec.dt4;
ar >> rec.dtm;
ar >> rec.dtg;
ar >> rec.srd;
ar >> rec.srm;
ar >> rec.srg;

m_data.SetAt(i,rec);
}
}
}

/////////////////////////////////////////////////////////////////////////////
// CMDIDoc diagnostics

#ifdef _DEBUG
void CMDIDoc::AssertValid() const
{
CDocument::AssertValid();
}

void CMDIDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMDIDoc commands

// MDIView.cpp : implementation of the CMDIView class
//

#include "stdafx.h"
#include "MDI.h"

#include "MDIDoc.h"
#include "MDIView.h"
#include "MyDialog.h"
#include "MyDialog2.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMDIView

IMPLEMENT_DYNCREATE(CMDIView, CView)

BEGIN_MESSAGE_MAP(CMDIView, CView)
//{{AFX_MSG_MAP(CMDIView)
ON_COMMAND(ID_MYBUTTON, OnMybutton)
ON_COMMAND(ID_MYBUTTON2, OnMybutton2)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMDIView construction/destruction

CMDIView::CMDIView()
{
// TODO: add construction code here

}

CMDIView::~CMDIView()
{
}

BOOL CMDIView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs

return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CMDIView drawing

void CMDIView::OnDraw(CDC* pDC)
{
CMDIDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc); // TODO: add draw code for native data here
CString s;

int i = pDoc->m_data.GetSize();

pDC->TextOut(10, 0, s);
for (int j=0; j<(i-1); j++) {
s.Format("%2d. %10s %10s %2d - %2d - %2d %2d - %2d - %2d ",(j+1),
pDoc->m_data.GetAt(j).naim,
pDoc->m_data.GetAt(j).otd,
pDoc->m_data.GetAt(j).dt4,
pDoc->m_data.GetAt(j).dtm,
pDoc->m_data.GetAt(j).dtg,
pDoc->m_data.GetAt(j).srd,
pDoc->m_data.GetAt(j).srm,
pDoc->m_data.GetAt(j).srg);
pDC->TextOut(10, (20+j*20), s);
}
}

/////////////////////////////////////////////////////////////////////////////
// CMDIView printing

BOOL CMDIView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}

void CMDIView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}

void CMDIView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CMDIView diagnostics

#ifdef _DEBUG
void CMDIView::AssertValid() const
{
CView::AssertValid();
}

void CMDIView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}

CMDIDoc* CMDIView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMDIDoc)));
return (CMDIDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMDIView message handlers

CMDIView* CMDIView::GetView()
{
CMDIChildWnd * pChild =
((CMDIFrameWnd*)(AfxGetApp()->m_pMainWnd))->MDIGetActive();

if ( !pChild )
return NULL;

CView * pView = pChild->GetActiveView();

if ( !pView )
return NULL;

// Ошибка, если Вид неправильного типа
if ( ! pView->IsKindOf( RUNTIME_CLASS(CMDIView) ) )
return NULL;

return (CMDIView *) pView;
}

void CMDIView::OnInitialUpdate()
{
CView::OnInitialUpdate();
CMDIDoc* pDoc = GetDocument();
}

void CMDIView::OnMybutton()
{
CMDIDoc* pDoc = GetDocument();
CMyDialog MyD;
MyD.DoModal(); // создаём новый диалог
STRUCTRECORD rec;
if (MyD.m_naim!="")
{
rec.naim = MyD.m_naim;
rec.otd = MyD.m_otd;
rec.dt4 = MyD.m_dt4;
rec.dtm = MyD.m_dtm;
rec.dtg = MyD.m_dtg;
rec.srd = MyD.m_srd;
rec.srm = MyD.m_srm;
rec.srg = MyD.m_srg;
int i = pDoc->m_data.GetSize();
pDoc->m_data.SetAt((i-1),rec); // получаем новые значения
pDoc->m_data.SetSize((i+1),1); // увеличиваем размер массива
OnInitialUpdate(); // синхронизируем данные
Invalidate( TRUE ); // перерисовываем экран(вызов OnDraw())
pDoc->SetModifiedFlag(); // ставим флаг изменения документа
}
}

void CMDIView::OnMybutton2()
{
CMDIDoc* pDoc = GetDocument();
CMyDialog2 MyD;
MyD.DoModal();
OnInitialUpdate(); // синхронизируем данные
Invalidate( TRUE ); // перерисовываем экран(вызов OnDraw())
pDoc->SetModifiedFlag();
}

// MyDialog2.cpp : implementation file
//

#include "stdafx.h"
#include "MDI.h"
#include "MDIDoc.h"
#include "MDIView.h"
#include "MyDialog2.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMyDialog2 dialog

CMyDialog2::CMyDialog2(CWnd* pParent /*=NULL*/)
: CDialog(CMyDialog2::IDD, pParent)
{
//{{AFX_DATA_INIT(CMyDialog2)
n = 0;
//}}AFX_DATA_INIT
}
void CMyDialog2::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMyDialog2)
DDX_Control(pDX, IDC_LIST1, m_l);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMyDialog2, CDialog)
//{{AFX_MSG_MAP(CMyDialog2)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMyDialog2 message handlers

void CMyDialog2::OnButton1() //..........работает
{
// TODO: Add your control notification handler code here
m_l.ResetContent();
int i = CMDIDoc::GetDoc()->m_data.GetSize();
CString str;
UpdateData(true);
for (int j=0; j<(i-1); j++) {
str.Format("%2d.Наименование %10s Отдел %10s Дата изготовления %2d - %2d - %2d Срок хранения %2d - %2d - %2d ",(j+1),
CMDIDoc::GetDoc()->m_data.GetAt(j).naim,
CMDIDoc::GetDoc()->m_data.GetAt(j).otd,
CMDIDoc::GetDoc()->m_data.GetAt(j).dt4,
CMDIDoc::GetDoc()->m_data.GetAt(j).dtm,
CMDIDoc::GetDoc()->m_data.GetAt(j).dtg,
CMDIDoc::GetDoc()->m_data.GetAt(j).srd,
CMDIDoc::GetDoc()->m_data.GetAt(j).srm,
CMDIDoc::GetDoc()->m_data.GetAt(j).srg );
m_l.AddString(str); UpdateData(false);
}
}
void CMyDialog2::OnButton2() //..........работает
{ // TODO: Add your control notification handler code here
m_l.ResetContent();
}
void CMyDialog2::OnButton3()
{
m_l.ResetContent();
int i = CMDIDoc::GetDoc()->m_data.GetSize();
CString str;
int j,d,m,g,d1;
UpdateData(true);
{
for ( j=0; j<(i-1); j++) {
d1=CMDIDoc::GetDoc()->m_data.GetAt(j).dtm;
d=CMDIDoc::GetDoc()->m_data.GetAt(j).dt4+CMDIDoc::GetDoc()->m_data.GetAt(j).srd;
m=CMDIDoc::GetDoc()->m_data.GetAt(j).dtm+CMDIDoc::GetDoc()->m_data.GetAt(j).srm;
g=CMDIDoc::GetDoc()->m_data.GetAt(j).dtg+CMDIDoc::GetDoc()->m_data.GetAt(j).srg;
if ((d1==1)||(d1==3)||(d1==5)||(d1==7)||(d1==8)||(d1==10)||(d1==12))
{ if (d>31)
{d-=31; m++;}
}
else if (d1==2)
{ if (d>28)
{d-=28; m++;}
}
else if (d>30)
{d-=30; m++;}
if (m>12) g++;
str.Format("%d. Наименование %10s Отдел %10s Срок реализации: %2d - %2d - %4d",(j+1),
CMDIDoc::GetDoc()->m_data.GetAt(j).naim,
CMDIDoc::GetDoc()->m_data.GetAt(j).otd,
d,m,g );
m_l.AddString(str); UpdateData(false);
}

}
}
Категория: Другое | Добавил: OlyaL
Просмотров: 2026 | Загрузок: 69
Всего комментариев: 0
Добавлять комментарии могут только зарегистрированные пользователи.
[ Регистрация | Вход ]