// Setting.cpp : implementation file #include "stdafx.h" #include "Setting.h" #include "Kurs_LipinDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CSetting dialog CSetting::CSetting(CKurs_LipinDlg* pParent) : CDialog(CSetting::IDD, pParent) { f_start=false; parent = pParent; //{{AFX_DATA_INIT(CSetting) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT } void CSetting::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CSetting) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CSetting, CDialog) //{{AFX_MSG_MAP(CSetting) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CSetting message handlers BOOL CSetting::OnInitDialog() { CDialog::OnInitDialog(); myFont.CreateFont(11,0,0,0,0,false,false,false,0,0,0,0,0,"Courier Cyr"); int count=1, w=30,h=20,x0=45,y0=10; for (int i=0; i < 29; i++) { for (int j=i; j < 29; j++) { if (i == j) { t_edit[i][j].Create (WS_CHILD|WS_VISIBLE | WS_TABSTOP | WS_DLGFRAME|TA_LEFT, CRect(j*w+x0-35,i*h+y0,(j+1)*w-1+x0,(i+1)*h-1+y0),this,100); t_edit[i][j].SetFont (&myFont); t_edit[i][j].SetWindowText(parent->name_city[i]); t_edit[i][j].SetReadOnly (); } else { t_edit[i][j].Create (WS_CHILD|WS_VISIBLE | WS_TABSTOP | WS_DLGFRAME, CRect(j*w+x0,i*h+y0,(j+1)*w-1+x0,(i+1)*h-1+y0),this,100);//count++); t_edit[i][j].SetFont (&myFont); t_edit[i][j].SetLimitText(4); } } } CStdioFile f1; int i; f1.Open("table.ini",CFile::modeRead); for ( i=0; i < 29; i++) { CString s1; f1.ReadString(s1); int j=i+1; int k=0; while (j<29 && k < s1.GetLength()) {CString s2; while (s1[k] == ' ') k++; while (s1[k] != ' ') { s2 += s1[k]; k++;} t_edit[i][j].SetWindowText(s2); j++; } } Proverka(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CSetting::OnOK() { Proverka(); CStdioFile f1; f1.Open("table.ini",CFile::modeCreate | CFile::modeWrite); for (int i=0; i < 29; i++) { parent->tableAllCity[i][i]=0; CString s1; for (int j=i+1; j < 29; j++) { CString s2; t_edit[i][j].GetWindowText(s2); parent->tableAllCity[j][i]=parent->tableAllCity[i][j]=atoi(s2); s1 += s2+" "; } s1 += "\n"; f1.WriteString(s1); } MessageBox("Ââåä¸ííûå ïàðàìåòðû ïðîâåðåíû íà îøèáêè è ñîõðàíåíû.", "Warrning!" ); CDialog::OnCancel (); } void CSetting::Proverka() { for (int i=0; i < 29; i++) { for (int j=i+1; j < 29; j++) { CString s1; t_edit[i][j].GetWindowText(s1); if (!s1.IsEmpty()) { for (int k=0; k < s1.GetLength(); k++) if (s1[k]<'0' || s1[k]>'9') {s1.Delete(k,1);k--;} if (s1.IsEmpty()) s1='0'; } else s1='0'; t_edit[i][j].SetWindowText(s1); } } }