Добавил:
Studfiles2
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Программы для выполнения лаб 1 и 2 / KALMAN / SOURCE / TXSETUPB
.CPP/* Project first
Copyright © 1997 by US. All Rights Reserved.
SUBSYSTEM: first.exe Application
FILE: txsetupb.cpp
AUTHOR: US
OVERVIEW
========
Source file for implementation of TXSetupB (TDialog).
*/
#include <owl\owlpch.h>
#pragma hdrstop
#include "txsetupb.h"
#include "tools.h"
//
// Build a response table for all messages/commands handled
// by the application.
//
DEFINE_RESPONSE_TABLE1(TXSetupB, TDialog)
//{{TXSetupBRSP_TBL_BEGIN}}
EV_BN_CLICKED(IDC_NEXT-1000, NextBNClicked),
EV_BN_CLICKED(IDC_BACK-1000, BackBNClicked),
//{{TXSetupBRSP_TBL_END}}
END_RESPONSE_TABLE;
//{{TXSetupB Implementation}}
TXSetupB::TXSetupB (TWindow* parent, FirstSetupList &results, TResId resId, TModule* module):
TDialog(parent, resId, module),
w_data(results), result(SetupStopped)
{
MView = new TEdit(this, IDC_MVIEW, SetupNumbersLength, 0);
FView = new TEdit(this, IDC_FVIEW, SetupNumbersLength, 0);
KfView = new TEdit(this, IDC_KFVIEW, SetupNumbersLength, 0);
SMEdit = new TEdit(this, IDC_MEDIT+10, SetupNumbersLength, 0);
SFEdit = new TEdit(this, IDC_FEDIT+10, SetupNumbersLength, 0);
SKfEdit = new TEdit(this, IDC_KFEDIT+10, SetupNumbersLength, 0);
BackButton = new TOwnerButton(this, IDC_BACK-1000, 0);
NextButton = new TOwnerButton(this, IDC_NEXT-1000, 0);
}
TXSetupB::~TXSetupB ()
{
Destroy();
}
void TXSetupB::NextBNClicked ()
{
result = SetupContinue;
CloseWindow(IDOK);
}
void TXSetupB::BackBNClicked ()
{
result = SetupBack;
CloseWindow(IDCANCEL);
}
BOOL TXSetupB::CanClose ()
{
if (!TDialog::CanClose())
return FALSE;
if (result == SetupContinue)
{
if (CheckFloatEditor(this, SMEdit, SetupNumbersLength, &w_data.Root->sm, "m должно") ||
CheckFloatEditor(this, SFEdit, SetupNumbersLength, &w_data.Root->sf, "f должно") ||
CheckFloatEditor(this, SKfEdit, SetupNumbersLength, &w_data.Root->skf, "kf должно"))
return FALSE;
}
return TRUE;
}
BOOL TXSetupB::EvInitDialog (HWND hWndFocus)
{
BOOL result;
FirstSetup *p = w_data.Root;
unsigned index;
char buffer[12];
result = TDialog::EvInitDialog(hWndFocus);
sprintf(buffer, "%lf", p->sm);
killZeros(buffer);
MView->Clear();
MView->Insert(buffer);
sprintf(buffer, "%lf", p->sf);
killZeros(buffer);
FView->Clear();
FView->Insert(buffer);
sprintf(buffer, "%lf", p->skf);
killZeros(buffer);
KfView->Clear();
KfView->Insert(buffer);
sprintf(buffer, "%lf", p->sm);
killZeros(buffer);
SMEdit->Clear();
SMEdit->Insert(buffer);
sprintf(buffer, "%lf", p->sf);
killZeros(buffer);
SFEdit->Clear();
SFEdit->Insert(buffer);
sprintf(buffer, "%lf", p->skf);
killZeros(buffer);
SKfEdit->Clear();
SKfEdit->Insert(buffer);
SetDefaultId(IDC_NEXT-1000);
return result;
}
void TXSetupB::SetupWindow ()
{
TDialog::SetupWindow();
// Position window to the center of desktop
TRect dialog_pos;
RECT desktop_pos;
unsigned dcx, dcy, sx, sy;
GetWindowRect(dialog_pos);
::GetWindowRect(GetDesktopWindow(), &desktop_pos);
dcx = desktop_pos.left + desktop_pos.right;
dcy = desktop_pos.top + desktop_pos.bottom;
sx = dialog_pos.right - dialog_pos.left;
sy = dialog_pos.bottom - dialog_pos.top;
dialog_pos.left = (dcx - sx) >> 1;
dialog_pos.right = (dcx + sx) >> 1;
dialog_pos.top = (dcy - sy) >> 1;
dialog_pos.bottom = (dcy + sy) >> 1;
MoveWindow(dialog_pos, FALSE);
}
Соседние файлы в папке SOURCE