Добавил:
Studfiles2
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Лабораторная работа 33 / Controller / ControllerDlg
.cpp// ControllerDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Controller.h"
#include "ControllerDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CControllerDlg dialog
CControllerDlg::CControllerDlg(CWnd* pParent /*=NULL*/)
: CDialog(CControllerDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CControllerDlg)
m_base = 0;
m_cnt = 0;
m_delindex = 0;
m_height = 0;
m_num = 1;
m_text = _T("");
m_x = 0;
m_y = 0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
if (!serv.CreateDispatch("part32.Document"))
{
AfxMessageBox("Ошибка при старте Serv!");
return;
}
}
void CControllerDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CControllerDlg)
DDX_Control(pDX, IDC_FIGS, m_figs);
DDX_Text(pDX, IDC_BASE, m_base);
DDX_Text(pDX, IDC_CNT, m_cnt);
DDX_Text(pDX, IDC_DELINDEX, m_delindex);
DDX_Text(pDX, IDC_HEIGHT, m_height);
DDX_Text(pDX, IDC_SETNUMBER, m_num);
DDV_MinMaxInt(pDX, m_num, 1, 2);
DDX_Text(pDX, IDC_TEXT, m_text);
DDX_Text(pDX, IDC_X, m_x);
DDX_Text(pDX, IDC_Y, m_y);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CControllerDlg, CDialog)
//{{AFX_MSG_MAP(CControllerDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_STARTSERV, OnStartserv)
ON_BN_CLICKED(IDC_CREATE, OnCreate)
ON_BN_CLICKED(IDC_DELETE, OnDelete)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CControllerDlg message handlers
BOOL CControllerDlg::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
m_figs.AddString("1 Треугольник");
m_figs.AddString("2 Трапеция");
m_figs.AddString("3 Трапеция с текстом");
m_figs.AddString("4 Текст");
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 CControllerDlg::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 CControllerDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CControllerDlg::OnStartserv()
{
// TODO: Add your control notification handler code here
serv.showWnd();
}
void CControllerDlg::OnCreate()
{
UpdateData(true);
int nom=m_figs.GetCaretIndex();
if (nom==0)
{
if ((m_x==0)&&(m_y==0)&&(m_base==0)&&(m_height==0))
{
AfxMessageBox("Не заданы нужные пераметры!");
return;
}
serv.Triangle(m_x,m_y,m_base,m_height,m_num);
}
else
if (nom==1)
{
if ((m_x==0)&&(m_y==0)&&(m_base==0)&&(m_height==0))
{
AfxMessageBox("Не заданы нужные пераметры!");
return;
}
serv.Trapezium(m_x,m_y,m_base,m_height,10,m_num);
}
else
if (nom==2)
{
if ((m_x==0)&&(m_y==0)&&(m_base==0)&&(m_height==0)&&(m_text==""))
{
AfxMessageBox("Не заданы нужные пераметры!");
return;
}
serv.TextTrapezium(m_x,m_y,m_base,m_height,10,m_text,m_num);
}
else
if (nom==3)
{
if ((m_x==0)&&(m_y==0)&&(m_text==""))
{
AfxMessageBox("Не заданы нужные пераметры!");
return;
}
serv.text(m_x,m_y,m_text,m_num);
}
m_cnt=serv.getCount(m_num);
UpdateData(false);
}
void CControllerDlg::OnDelete()
{
UpdateData(true);
serv.DeleteElem(m_delindex,m_num);
m_cnt=serv.getCount(m_num);
UpdateData(false);
}
Соседние файлы в папке Controller