CButton*cbpr2=(CButton*)GetDlgItem(IDC_RADIO2);
CButton*cbpr3=(CButton*)GetDlgItem(IDC_RADIO3);
cbpr1->SetCheck(radio1);
cbpr2->SetCheck(radio2);
cbpr3->SetCheck(radio3);
return TRUE; */
{
char temp1[10];
CDialog::OnInitDialog();
CListBox *d=(CListBox*)GetDlgItem(IDC_LIST2);
for(int i1=0;i1<ind;i1++)
{
sprintf(temp1,"%d",i1);
d->AddString(temp1);
}
char temp2[10];
CDialog::OnInitDialog();
CListBox *k=(CListBox*)GetDlgItem(IDC_LIST3);
for(int i2=0;i2<ind;i2++)
{
sprintf(temp2,"%d",i2);
k->AddString(temp2);
}
return TRUE;
}
void CMyDialog::OnLIST2()
{
//here we are getting list pointer with indentifier IDC_LIST1
CListBox* lbd=(CListBox*)GetDlgItem(IDC_LIST2);
//after obtaining the pointer,we are defining index of selected element
inde=lbd->GetCurSel();
//find out name of selected element
lbd->GetText(inde,listStr);
MessageBox(listStr,"Selection is");
}
void CMyDialog::OnLIST3()
{
//here we are getting list pointer with indentifier IDC_LIST1
CListBox* lbk=(CListBox*)GetDlgItem(IDC_LIST3);
//after obtaining the pointer,we are defining index of selected element
ind=lbk->GetCurSel();
//find out name of selected element
lbk->GetText(ind, listStr);
MessageBox(listStr,"Selection is");
}
float C;
const char szPashaWndTitle[] = "Pasha's application uses MFC";
const StepNum = 20;
bool bRunned;
class CPashaWnd : public CFrameWnd
{
public:
_int16 *NewArray16;
CPashaWnd()
{
NumOfRow = 2;
bRunned = false;
RECT r;
r.top=r.left=50;
r.bottom=r.right=500;
Create(NULL,"In any business the most difficul is beginning",
WS_OVERLAPPEDWINDOW|WS_VISIBLE,r,NULL,MAKEINTRESOURCE(IDR_MENU1));
};
~CPashaWnd() {};
afx_msg void OnOPEN();
afx_msg void OnHELP();
afx_msg void OnSAVE();
afx_msg void OnINFO();
afx_msg void OnRENAME();
afx_msg void OnCreateChildWindow();
afx_msg void OnQUIT();
afx_msg void OnDialog();
afx_msg void OnRUUN();
afx_msg void OnRESULT();
afx_msg void OnPaint();
afx_msg void OnRogy();
afx_msg void OnINPUT();
DECLARE_MESSAGE_MAP()
int NumOfRow;
};
BEGIN_MESSAGE_MAP( CPashaWnd, CFrameWnd)
ON_COMMAND( ID_CHILD,OnCreateChildWindow)
ON_COMMAND( ID_CHILDNEXT,OnRogy)
ON_COMMAND( ID_FILE_OPEN, OnOPEN)
ON_COMMAND( ID_FILE_INFO, OnINFO)
ON_COMMAND( ID_FILE_HELP, OnHELP)
ON_COMMAND( ID_FILE_SAVE, OnSAVE)
ON_COMMAND( ID_RUUN_RUUN, OnRUUN)
ON_COMMAND( AFX_ID_FILE_RENAME, OnRENAME)
ON_COMMAND( AFX_ID_FILE_QUIT, OnQUIT)
// ON_COMMAND( AFX_ID_RUN_RUN, OnRUN)
ON_COMMAND( AFX_ID_RESUET_RESUET, OnRESULT)
ON_COMMAND( AFX_ID_FILE_Dialog, OnDialog)
END_MESSAGE_MAP()
//-------------------------------------------------------------------
class CChildWnd:public CFrameWnd
{
protected:
POINT p;
afx_msg void OnPaint();
DECLARE_MESSAGE_MAP();
public:
CChildWnd(CWnd *pParent)
{
CRect wndSize(0,0,300,300);
Create(NULL,"ChildWindow",WS_OVERLAPPEDWINDOW|
WS_CHILD,wndSize,pParent);
}
};
BEGIN_MESSAGE_MAP(CChildWnd,CFrameWnd)
ON_WM_PAINT()
END_MESSAGE_MAP()
void CChildWnd::OnPaint()
{
CPaintDC dc(this);
if (!bRunned)
{
char str2[20];
CPen pen,pen1;
CRect rect;
CString tmp = _T("");
sprintf(str2," %f ",average);
pen.CreatePen(PS_SOLID, 2, RGB(0,250,0));
pen1.CreatePen(PS_SOLID, 2, RGB(255,255,255));
dc.SelectObject(&pen);
GetClientRect(&rect);
int step = (rect.right - rect.left) / StepNum;
int x = average * step + 50;
step = (rect.bottom - rect.top) / Nmax;
pen.DeleteObject();
CBrush brush,brush1,brush2,brush3;
brush.CreateSolidBrush(RGB(255,255,255));
brush2.CreateSolidBrush(RGB(255,200,255));
brush3.CreateSolidBrush(RGB(0,0,0));
brush1.CreateSolidBrush(RGB(255,255,255));
dc.SelectObject(&brush);
int y = rect.bottom - index*step;
int k,d,dy = 1;
int flag=1;
int top = 5;
k = top;
while(top < y)
{
dc.SelectObject(&brush2);
dc.SelectObject(&pen);
dc.Ellipse(x, k, x+30, k-30);
for(d=0;d<1000000;d++);
dc.SelectObject(&brush2);
dc.SelectObject(&pen1);
dc.Ellipse(x, k, x+30, k-30);
dc.SelectObject(&brush);
dc.SelectObject(&pen);
dc.Ellipse(x, k, x+30, k-30);
k += dy;
dy += flag;
if(k>y)
{ k = y;
dy = -dy/2;
flag = -1;
top += step; }
if(k<top)
{ k = top ;
dy = 1;
flag = 1; }
}
k-=15;
dc.SelectObject(&brush2);
dc.SelectObject(&pen1);
dc.Ellipse(x, k, x+30, k-30);
brush.DeleteObject();
}
}
int cnt=0;
//-----------------------------------------------------------------------
class CChildNextWnd:public CFrameWnd
{
protected:
POINT p;
afx_msg void OnPaint();
DECLARE_MESSAGE_MAP();
public:
CChildNextWnd(CWnd *pParent)
{
CRect wndSize(0,0,300,300);
Create(NULL,"ChildWindow",WS_OVERLAPPEDWINDOW|
WS_CHILD,wndSize,pParent);
}
};
BEGIN_MESSAGE_MAP(CChildNextWnd,CFrameWnd)
ON_WM_PAINT()
END_MESSAGE_MAP()
void CChildNextWnd::OnPaint()
{
CPaintDC dc(this);
char t[10];
int arr[10];
int i=0,n=0,j=0,m=0;
while(str1[n]!='\0')
{
while(isdigit(str1[n]))
{
t[i++]=str1[n];
n++;
}
if(i>0)
{t[i]='\0';i=0;arr[m++]=atoi(t);}
n++;
}
int a=50,b=80;
i=0;
//initialization of matrix by the numbers inputed in edit box
//int matrix[20][20];
for(m=0;m<ind;m++)
for(n=0;n<inde;n++)
matrix[m][n]=arr[i++];
_int16 *NewArray16=new _int16[ind*inde];
m=0;
for(i=0;i<ind;i++)
for(j=0;j<inde;j++)
NewArray16[m++]=(_int16)matrix[i][j];
for(m=0;m<ind*inde;m++)
{
NewArray16[m]=(_int16)matrix[i][j];
if(j==inde)
{
i++;j=0;
}
j++;
if(i==ind)
break;
}
int x=40,y=50;char buf[10];
//filling the screen by numbers that are in matrix
int temp;
int max = matrix[0][ind-1];
dc.TextOut(x,y-20,"Matrix");
for(m=0;m<ind;m++)
{
for(n=0;n<inde;n++)
{
temp=matrix[m][n];
sprintf(buf,"%d",temp);
dc.TextOut(x,y,buf,strlen(buf));
x+=30;
}
y+=20;
x=40;
}
{
//for (i = 0; i < inde; i++)
// if (matrix[i][inde- i - 1] > max)
//max=matrix[i][ind - i - 1];
}
ifstream in("out.dat");
if(!in)
cout<<"Figovina!";
else
{
in >> min >> max >> average;
in.close();
}; max = 10;
dc.TextOut(50,180,"Mах");
sprintf(buf,"%d",max);
dc.TextOut(90,180,buf);
}
//------------------------------------------------------------------
/*void CPashaWnd::OnRUN()
{
CClientDC dc(this);
char t[10];
int arr[10];
int i=0,n=0,j=0,m=0;
while(str1[n]!='\0')
{
while(isdigit(str1[n]))
{
t[i++]=str1[n];
n++;
}
if(i>0)
{t[i]='\0';i=0;arr[m++]=atoi(t);}
n++;
}
int a=50,b=80;
i=0;
//initialization of matrix by the numbers inputed in edit box
//int matrix[20][20];
for(m=0;m<ind;m++)
for(n=0;n<inde;n++)
matrix[m][n]=arr[i++];
_int16 *NewArray16=new _int16[ind*inde];
m=0;
for(i=0;i<ind;i++)
for(j=0;j<inde;j++)
NewArray16[m++]=(_int16)matrix[i][j];
for(m=0;m<ind*inde;m++)
{
NewArray16[m]=(_int16)matrix[i][j];
if(j==inde)
{
i++;j=0;
}
j++;
if(i==ind)
break;
}
/*int x=40,y=50;char buf[10];
//filling the screen by numbers that are in matrix
int temp;
dc.TextOut(x,y-20,"Matrix");
for(m=0;m<ind;m++)
{
for(n=0;n<inde;n++)
{
temp=matrix[m][n];
sprintf(buf,"%d",temp);
dc.TextOut(x,y,buf,strlen(buf));
x+=30;
}
y+=20;
x=40;
}
//here we find out 'Min' element of row that was selected in ListBox
min=matrix[index][0];
for(m=1;m<inde;m++)
if(min>matrix[index][m])
min=matrix[index][m];
//here we find out 'Max' element of row that was selected in ListBox
max=matrix[index][0];
for(m=1;m<inde ;m++)
if(max<matrix[index][m])
max=matrix[index][m];
average=(max+min)/2;
dc.TextOut(60,140,"--This is the number of matrix row having been selected before");
dc.TextOut(50,140,listStr);
dc.TextOut(50,160,"Min");
sprintf(t,"%d",min);
dc.TextOut(90,160,t,strlen(t));
dc.TextOut(50,180,"Mах");
sprintf(t,"%d",max);
dc.TextOut(90,180,t);
dc.TextOut(50,200,"Average of Min and Max");
sprintf(t,"%d",average);
dc.TextOut(280,200,t);
bRunned=1;
//--------------------------------------------------------------
//CBrush brush(0,RGB(0,30,70));
//access=1;
//OnTimer(access);
bRunned=1;
}*/
// bRunned=1;
void CPashaWnd::OnRUUN()
{
system("oks.exe");
}
void CPashaWnd::OnRogy()
{
CChildNextWnd *pFrameWnd=new CChildNextWnd(this);
pFrameWnd->ShowWindow(1);
pFrameWnd->UpdateWindow();
}
void CPashaWnd::OnCreateChildWindow()
{
CChildWnd *pFrameWnd=new CChildWnd(this);
pFrameWnd->ShowWindow(1);
pFrameWnd->UpdateWindow();
}
void CPashaWnd::OnRESULT(){}
void CPashaWnd::OnSAVE()
{
// создание стандартной панели выбора файла SaveAs
CFileDialog DlgSaveAs(FALSE,(LPSTR)"*",NULL,OFN_ALLOWMULTISELECT ,
(LPSTR)"Dat Files(*.dat)|*.dat");
// отображение стандартной панели выбора файла SaveAs
if(DlgSaveAs.DoModal()==IDOK)
{
// создание объекта и открытие файла для записи
ofstream fout(DlgSaveAs.GetPathName());
if(!fout)
AfxMessageBox("File hasn't been created");
else
{
fout << ind << " ";
fout << inde << " ";
fout << index << " ";
for (int i=0; i<ind; i++)
for (int j=0; j<inde; j++)
{
fout << matrix[i][j] << " ";
}
fout.close();
system( "oks.exe");
} }}
void CPashaWnd::OnRENAME()
{
CClientDC dc(this);
CFileDialog DlgOpen(TRUE,(LPCSTR)"*",NULL,
OFN_HIDEREADONLY,(LPCSTR)" All Files (*.dat) |*.dat||");
if(DlgOpen.DoModal()==IDOK)
{
CStdioFile File(DlgOpen.GetPathName(),CFile::modeRead);
File.Close();
File.Remove(DlgOpen.GetPathName());
}
}
void CPashaWnd::OnQUIT()
{
PostQuitMessage( 0);
}
void CPashaWnd::OnHELP()
{
AfxMessageBox("НЕТ И НЕ БУДЕТ");
}
void CPashaWnd::OnINFO()
{
AfxMessageBox("СТУДЕНТ ГРУПИ 2КІ-98 ПАША");
}
void CPashaWnd::OnOPEN()
{
int i;
CClientDC dc(this);
CFileDialog DlgOpen(TRUE,(LPCSTR)"*",NULL,
OFN_HIDEREADONLY,(LPCSTR)" All Files (*.*) |*.*||");
int arr[50];
if(DlgOpen.DoModal()==IDOK)
{
char buf[255];
FILE *in;
if (in = fopen(DlgOpen.GetPathName(), "rt"))
{
fgets(buf, 255, in);
CString t = _T(buf);
dc.TextOut(10,10,t);
} } }
void CPashaWnd::OnDialog()
{
CMyDialog MyDialog;
MyDialog.DoModal();
bRunned = false;
}
void CPashaWnd::OnPaint()
{
CPaintDC dc(this);
int len;
len=strlen(buf1);
if(len)
{
dc.TextOut(20,180,"ListBox1:");
dc.TextOut(100,180,buf1,len);
}
len=strlen(buf2);
if(len)
{
dc.TextOut(20,210,"ListBox2:");
dc.TextOut(100,210,buf2,len);
}
len=strlen(str);
if(len)
{
dc.TextOut(20,240,"Edit:");
dc.TextOut(100,240,str,len);
}
}
class CPashaApp : public CWinApp
{
public:
CPashaApp() {};
virtual BOOL InitInstance();
};
BOOL CPashaApp::InitInstance()
{
m_pMainWnd= new CPashaWnd();
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return TRUE;
}
CPashaApp PashaApp;
Додаток 2.
Proba.rc
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
#include "afxres.h"
#undef APSTUDIO_READONLY_SYMBOLS
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_UKR)
#ifdef _WIN32
LANGUAGE 0x22, 0x1
#pragma code_page(1251)
#endif //_WIN32
IDR_MENU1 MENU DISCARDABLE
BEGIN
POPUP "&FILE"
BEGIN
MENUITEM "OPEN", ID_FILE_OPEN
MENUITEM "SaveAs", ID_FILE_SAVE
MENUITEM "DELETE", AFX_ID_FILE_RENAME
END
MENUITEM "&INFO", ID_FILE_INFO
MENUITEM "&HELP", ID_FILE_HELP
POPUP "Cale"
BEGIN
MENUITEM "INPUT", AFX_ID_FILE_Dialog
MENUITEM "RUN", ID_CHILDNEXT
MENUITEM "&RESUET", ID_CHILD
END
MENUITEM "QUIT", AFX_ID_FILE_QUIT
END
#ifdef APSTUDIO_INVOKED
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
IDR_ACCELERATOR1 ACCELERATORS DISCARDABLE
BEGIN
"I", ID_HELP_INFO, VIRTKEY, CONTROL, NOINVERT
VK_F10, ID_FILE_EXIT, VIRTKEY, CONTROL, NOINVERT
END
IDD_DIALOG DIALOG DISCARDABLE 0, 0, 307, 140
STYLE DS_MODALFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP |
WS_CAPTION | WS_SYSMENU
CAPTION "Dialog"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDC_OK,145,45,50,14
PUSHBUTTON "Cancel",IDCANCEL,225,45,50,14
LISTBOX IDC_LIST2,5,85,48,18,LBS_SORT | LBS_NOINTEGRALHEIGHT |
WS_VSCROLL | WS_TABSTOP
EDITTEXT IDC_EDIT1,190,110,49,19,ES_AUTOHSCROLL
CONTROL "BYTE",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON,25,10,35,
10
CONTROL "WORD",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON,115,10,39,
10
CONTROL "DWORD",IDC_RADIO3,"Button",BS_AUTORADIOBUTTON,195,10,45,
10
LTEXT "ъ¦ы№ъ¦ёЄ№ Ё фъ¦т",ID_STATIC,65,50,56,8
LTEXT "ъ¦ы№ъ¦ёЄ№ ёЄютяўшъ¦т",ID_STATIC2,60,90,71,8
LTEXT "¦LT¦Lг-",IDC_STATIC,195,95,37,8
LTEXT "List Box",IDC_STATIC,20,70,25,10
LTEXT "List Box",IDC_STATIC,15,110,26,8
LISTBOX IDC_LIST3,5,40,50,20,LBS_SORT | LBS_NOINTEGRALHEIGHT |
WS_VSCROLL | WS_TABSTOP
END
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_DIALOG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 297
BOTTOMMARGIN, 133
END
END
#endif // APSTUDIO_INVOKED
STRINGTABLE DISCARDABLE
BEGIN
AFX_ID_FILE_RENAME "RENAME"
AFX_ID_FILE_QUIT "QUIT"
AFX_ID_RESUET_RESUET "RESUET"