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

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

ТРПОСУ 4 семестр 11 вариант
Подробности о скачивании 05.12.2011, 20:07
Лабораторная работа №1.
Мастера Сlassview и Сlasswizard в Visual C++ 6.0

11. .

// 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=(sqrt(pow((3*y+2), 2)-24*y))/((3*sqrt(y))-(2/sqrt(y)));
z2=-sqrt(y);
}

void x::print() // метод для вывода результатов
{
CString str;
/* объявили строковый объект класса библиотеки MFC, и при помощи его вызвали метод, который работает как стандартная функция printf(…), но выводит значения объектов из списка вывода в указанную строку*/
str.Format("Для X =%5.2f\nZ1 =%5.2f\nZ2 =%5.2f",y, z1, z2);
AfxMessageBox(str);
}
void x::set(double a) // метод для инициализации класса
{
y=a;
}

// 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_x = 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)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
//}}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); // данные считываються из элементов управления диалогового окна
//и обновляються переменные оконного объекта
if ((m_x<=0)||(m_x==2/3)) // проверка исходных данных на отсутствие решения
AfxMessageBox("Значение должно быть больше 0 и не равно 2/3\n Bведите новое значение!");
else {
x x1; // Конструктор класса x создает объект x1
x1.set(m_x); // инициализация данных
x1.run(); // вычисление
x1.print(); // вывод
}
UpdateData(FALSE); // обновляет содержимое элементов управления диалогового окна
}

void CZadacha_1Dlg::OnButton2()
{
OnOK();
}





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

11.

// zadacha_3Dlg.cpp : implementation file
//

#include "stdafx.h"
#include "zadacha_3.h"
#include "zadacha_3Dlg.h"
#include "math.h"

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

/////////////////////////////////////////////////////////////////////////////
// CZadacha_3Dlg dialog

CZadacha_3Dlg::CZadacha_3Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CZadacha_3Dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CZadacha_3Dlg)
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 CZadacha_3Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CZadacha_3Dlg)
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(CZadacha_3Dlg, CDialog)
//{{AFX_MSG_MAP(CZadacha_3Dlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CZadacha_3Dlg message handlers

BOOL CZadacha_3Dlg::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_3Dlg::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_3Dlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
int i,m_n;
double x,m_x1,m_x2,m_h,s,y,fak;
CString str;

void CZadacha_3Dlg::OnButton1()
{
UpdateData(true);
m_l.ResetContent ();// очиска на случай если не была произведена очистка
str.Format("datas: x1=%.2f, x2=%.2f, h=%.2f, n=%d", m_x1, m_x2, m_h, m_n);
m_l.AddString(str);
UpdateData(false);
for (x=m_x1;x<=m_x2;x+=m_h)
{s=1;fak=1;
y=(1+2*pow(x,2))*exp(pow(x,2));
for(i=1;i<=m_n;i++)
{
fak*=i;
s+=(2*i+1)/fak*pow(x,2*i);
}
str.Format("Для x=%.2f, сумма=%.2f, y=%.2f", x,s,y);
m_l.AddString(str);

UpdateData(true);
}
//UpdateData(FALSE);
}
void CZadacha_3Dlg::OnButton2()
{
// TODO: Add your control notification handler code here
m_l.ResetContent ();
}





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

1.

// 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

const double pi=3.14159265;
/////////////////////////////////////////////////////////////////////////////
// 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(100000);
//устанавливаем положение ползунка
//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*pi; //считывание из диалога нач. значения.
double h=(d.m_b*pi-x)/m_slider.GetPos(); //вычисление h=(b-a)/N
int i=0;
while(x<d.m_b*pi)
{ double f=sin(x); //вычисление синуса
s+=f*h; // вычисление суммы
x+=h;
m_progress.SetPos(100*i++/m_slider.GetPos());
//установка положения в полосе Progress
}m_res=s;
UpdateData(0);
}


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

11. В налоговой инспекции содержатся данные о предприятиях, которые определяют название, УНП, ФИО директора, вид деятельности, дата регистрации. Вывести все предприятия по видам деятельности (исключать ликвидированные).

// 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).naz;
ar << m_data.GetAt(i).unp;
ar << m_data.GetAt(i).fio;
ar << m_data.GetAt(i).vid;
ar << m_data.GetAt(i).reg;
ar << m_data.GetAt(i).likv;
}
}
else
{
int size;
STRUCTRECORD rec;
ar >> size;
m_data.SetSize(size, 1);
for (int i=0; i < size; i++)
{
ar >> rec.naz;
ar >> rec.unp;
ar >> rec.fio;
ar >> rec.vid;
ar >> rec.reg;
ar >> rec.likv;
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();
for (int j=0; j<(i-1); j++)
{
s.Format("%2d. %-20s %-9s %-20s %-20s %-10s",(j+1),
pDoc->m_data.GetAt(j).naz,
pDoc->m_data.GetAt(j).unp,
pDoc->m_data.GetAt(j).fio,
pDoc->m_data.GetAt(j).vid,
pDoc->m_data.GetAt(j).reg);
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_naz!="")
{
rec.naz = MyD.m_naz;
rec.unp = MyD.m_unp;
rec.fio = MyD.m_fio;
rec.vid = MyD.m_vid;
rec.reg = MyD.m_reg;
rec.likv = MyD.m_likv;
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)
//}}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() //..........работает
{
m_l.ResetContent();
int i = CMDIDoc::GetDoc()->m_data.GetSize();
CString str;
UpdateData(true);
for (int j=0; j<(i-1); j++)
{
str.Format("%d. Название: %-20s УНП: %-9s ФИО: %-20s Вид: %-20s Дата: %-10s",(j+1),
CMDIDoc::GetDoc()->m_data.GetAt(j).naz,
CMDIDoc::GetDoc()->m_data.GetAt(j).unp,
CMDIDoc::GetDoc()->m_data.GetAt(j).fio,
CMDIDoc::GetDoc()->m_data.GetAt(j).vid,
CMDIDoc::GetDoc()->m_data.GetAt(j).reg);
m_l.AddString(str);
UpdateData(false);
}
}
void CMyDialog2::OnButton2() //..........работает
{
m_l.ResetContent();
}
void CMyDialog2::OnButton3()
{
m_l.ResetContent();
int i = CMDIDoc::GetDoc()->m_data.GetSize();
CString str,d;
int j,j1=0;
UpdateData(true);
STRUCTRECORD temp;
CArray <STRUCTRECORD, STRUCTRECORD> m_data2;
m_data2.SetSize(i, 1);
for ( j=0; j<(i-1); j++)
m_data2[j]=CMDIDoc::GetDoc()->m_data.GetAt(j);
for ( j=0; j<(i-1); j++)
{for ( j1=(i-2); j1>j; j1--)
{
if (m_data2[j1-1].vid<m_data2[j1].vid)
{
temp=m_data2[j1];
m_data2[j1]=m_data2[j1-1];
m_data2[j1-1]=temp;
}
}
}
int k=1;
for ( j=(i-2); j>=0; j--)
{
if (m_data2[j].likv==false)
{ str.Format("%d. Вид: %-20s Название: %-20s УНП: %-9s ФИО: %-20s Дата: %-10s",k,
m_data2[j].vid,
m_data2[j].naz,
m_data2[j].unp,
m_data2[j].fio,
m_data2[j].reg);
m_l.AddString(str);
k++;
UpdateData(false);
}
}

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