?? 最近鄰法分類器dlg.cpp
字號:
DSS_NORMAL|DST_ICON ,
(CBrush*)NULL);
GetDlgItem(IDC_STATICN2)->GetWindowRect(rectp);ScreenToClient(rectp);
rcIcon1.left=rectp.left-37;
rcIcon1.right=rcIcon1.left+32;
rcIcon1.top=rectp.top-6;
rcIcon1.bottom=rcIcon1.top+32;
pDC->DrawState(rcIcon1.TopLeft(),
rcIcon1.Size(),
Sicon1,
DSS_NORMAL|DST_ICON ,
(CBrush*)NULL);
}
if(f1)
{
CRect rectp,rcIcon1;
GetDlgItem(IDC_STATIC3)->GetWindowRect(rectp);ScreenToClient(rectp);
rcIcon1.left=rectp.left+rectp.Width()/2-16;
rcIcon1.right=rcIcon1.left+32;
rcIcon1.top=rectp.top+16;
rcIcon1.bottom=rcIcon1.top+32;
pDC->DrawState(rcIcon1.TopLeft(),
rcIcon1.Size(),
sion1,
DSS_NORMAL|DST_ICON ,
(CBrush*)NULL);
}
if(f2)
{
CRect rectp,rcIcon1;
GetDlgItem(IDC_STATIC3)->GetWindowRect(rectp);ScreenToClient(rectp);
rcIcon1.left=rectp.left+rectp.Width()/2-16;
rcIcon1.right=rcIcon1.left+32;
rcIcon1.top=rectp.top+16;
rcIcon1.bottom=rcIcon1.top+32;
pDC->DrawState(rcIcon1.TopLeft(),
rcIcon1.Size(),
sion2,
DSS_NORMAL|DST_ICON ,
(CBrush*)NULL);
}
if(f3)
{
CRect rectp,rcIcon1;
GetDlgItem(IDC_STATIC3)->GetWindowRect(rectp);ScreenToClient(rectp);
rcIcon1.left=rectp.left+rectp.Width()/2-16;
rcIcon1.right=rcIcon1.left+32;
rcIcon1.top=rectp.top+16;
rcIcon1.bottom=rcIcon1.top+32;
pDC->DrawState(rcIcon1.TopLeft(),
rcIcon1.Size(),
sion3,
DSS_NORMAL|DST_ICON ,
(CBrush*)NULL);
}
return false;
}
void CMyDlg::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
// TODO: Add your message handler code here and/or call default
m_mmenu.DrawItem(lpDrawItemStruct);
CDialog::OnDrawItem(nIDCtl, lpDrawItemStruct);
}
void CMyDlg::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
// TODO: Add your message handler code here and/or call default
m_mmenu.MeasureItem(lpMeasureItemStruct);
CDialog::OnMeasureItem(nIDCtl, lpMeasureItemStruct);
}
void CMyDlg::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if(m_mmenu.FMouse2)
{
m_mmenu.FMouse2=false;DrawMenuBar( );
}
if(m_mmenu.FMouse1)
{
m_mmenu.FMouse1=false;DrawMenuBar( );
}
if(m_mmenu.FMouse3)
{
m_mmenu.FMouse3=false;DrawMenuBar( );
}
if(m_mmenu.FMouse4)
{
m_mmenu.FMouse4=false;DrawMenuBar( );
}
CDialog::OnMouseMove(nFlags, point);
}
void CMyDlg::OnNcMouseMove(UINT nHitTest, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CRect Mrect2(63,30,135,48);
CRect Mrect1(3,30,63,48);
CRect Mrect3(135,30,219,48);
CRect Mrect4(219,30,279,48);
CDC* dc=GetWindowDC();
dc->LPtoDP(Mrect2);
dc->LPtoDP(Mrect1);
dc->LPtoDP(Mrect3);
dc->LPtoDP(Mrect4);
if(Mrect2.PtInRect(point))
{
if(!m_mmenu.FMouse2)
{
m_mmenu.FMouse2=true;
DrawMenuBar( );
}
}
else
{
if(m_mmenu.FMouse2)
{
m_mmenu.FMouse2=false;
DrawMenuBar( );
}
}
if(Mrect1.PtInRect(point))
{
if(!m_mmenu.FMouse1)
{
m_mmenu.FMouse1=true;
DrawMenuBar( );
}
}
else
{
if(m_mmenu.FMouse1)
{
m_mmenu.FMouse1=false;
DrawMenuBar( );
}
}
if(Mrect3.PtInRect(point))
{
if(!m_mmenu.FMouse3)
{
m_mmenu.FMouse3=true;
DrawMenuBar( );
}
}
else
{
if(m_mmenu.FMouse3)
{
m_mmenu.FMouse3=false;
DrawMenuBar( );
}
}
if(Mrect4.PtInRect(point))
{
if(!m_mmenu.FMouse4)
{
m_mmenu.FMouse4=true;
DrawMenuBar( );
}
}
else
{
if(m_mmenu.FMouse4)
{
m_mmenu.FMouse4=false;
DrawMenuBar( );
}
}
}
void CMyDlg::OnClass11()
{
// TODO: Add your command handler code here
if(!ff1)
{
int i1=0,i2=0;
int x,y;
/* Seed the random-number generator with current time so that
* the numbers will be different every time we run.
*/
srand( (unsigned)time( NULL ) );
int i=0;
for(;i<240;i++)
{
*(onep+i)=0;
}
i=0;
while(i<120)
{
x=(int)(rand()%200);
y=(int)(rand()%200)+200;
BOOL flag=false;
if((x-100)*(x-100)+(y-300)*(y-300)<10000)
{
for(int j=0;j<i;j++)
{
if(*(onep+2*j)==x&&*(onep+2*j+1)==y)
{
flag=true;
j=i;
}
}
if(!flag)
{
*(onep+2*i)=x;
*(onep+2*i+1)=y;
}
i++;
}
}
ff1=true;
}
flag1=true;
CRect rectldj;
GetDlgItem(IDC_STATIC1)->GetWindowRect(rectldj);ScreenToClient(rectldj);
InvalidateRect(rectldj,true);
GetDlgItem(IDC_STATIC2)->GetWindowRect(rectldj);ScreenToClient(rectldj);
strcpy(m_k1.mychar,"第一類的點數: 120");
InvalidateRect(rectldj,true);
}
void CMyDlg::OnClass12()
{
// TODO: Add your command handler code here
if(!ff2)
{
int i1=0,i2=0;
int x,y;
/* Seed the random-number generator with current time so that
* the numbers will be different every time we run.
*/
srand( (unsigned)time( NULL ) );
int i=0;
for(;i<260;i++)
{
*(towp+i)=0;
}
i=0;
while(i<130)
{
x=(int)(rand()%200);
y=(int)(rand()%200);
BOOL flag=false;
if((x-100)*(x-100)+(y-100)*(y-100)<10000)
{
for(int j=0;j<i;j++)
{
if(*(towp+2*j)==x&&*(towp+2*j+1)==y)
{
flag=true;
j=i;
}
}
if(!flag)
{
*(towp+2*i)=x;
*(towp+2*i+1)=y;
}
i++;
}
}
ff2=true;
}
flag2=true;
CRect rectldj;
GetDlgItem(IDC_STATIC1)->GetWindowRect(rectldj);ScreenToClient(rectldj);
InvalidateRect(rectldj,true);
GetDlgItem(IDC_STATIC2)->GetWindowRect(rectldj);ScreenToClient(rectldj);
strcpy(m_k2.mychar,"第二類的點數: 130");
InvalidateRect(rectldj,true);
}
void CMyDlg::OnClass13()
{
// TODO: Add your command handler code here
if(!ff3)
{
int i1=0,i2=0;
int x,y;
/* Seed the random-number generator with current time so that
* the numbers will be different every time we run.
*/
srand( (unsigned)time( NULL ) );
int i=0;
for(;i<300;i++)
{
*(threep+i)=0;
}
i=0;
while(i<150)
{
x=(int)(rand()%200)+int(100*1.732)+1;
y=(int)(rand()%200)+100;
BOOL flag=false;
if((x-100-int(100*1.732)-1)*(x-100-int(100*1.732)-1)+(y-200)*(y-200)<10000)
{
for(int j=0;j<i;j++)
{
if(*(threep+2*j)==x&&*(threep+2*j+1)==y)
{
flag=true;
j=i;
}
}
if(!flag)
{
*(threep+2*i)=x;
*(threep+2*i+1)=y;
}
i++;
}
}
ff3=true;
}
flag3=true;
CRect rectldj;
GetDlgItem(IDC_STATIC1)->GetWindowRect(rectldj);ScreenToClient(rectldj);
InvalidateRect(rectldj,true);
GetDlgItem(IDC_STATIC2)->GetWindowRect(rectldj);ScreenToClient(rectldj);
strcpy(m_k3.mychar,"第三類的點數: 150");
InvalidateRect(rectldj,true);
}
void CMyDlg::OnClass21()
{
// TODO: Add your command handler code here
if(!ff4)
{
int i1=0,i2=0;
int x,y;
/* Seed the random-number generator with current time so that
* the numbers will be different every time we run.
*/
srand( (unsigned)time( NULL ) );
int i=0;
for(;i<600;i++)
{
*(test+i)=0;
}
i=0;
while(i<100)
{
x=(int)(rand()%200);
y=(int)(rand()%200)+200;
BOOL flag=false;
if((x-100)*(x-100)+(y-300)*(y-300)<10000)
{
for(int j=0;j<120;j++)
{
if(*(onep+2*j)==x&&*(onep+2*j+1)==y)
{
flag=true;
j=120;
}
}
if(!flag)
{
for(int k=0;k<i;k++)
{
if(*(test+2*k)==x&&*(test+2*k+1)==y)
{
flag=true;
k=i;
}
}
}
if(!flag)
{
*(test+2*i)=x;
*(test+2*i+1)=y;
}
i++;
}
}
while(i<200)
{
x=(int)(rand()%200);
y=(int)(rand()%200);
BOOL flag=false;
if((x-100)*(x-100)+(y-100)*(y-100)<10000)
{
for(int j=0;j<130;j++)
{
if(*(towp+2*j)==x&&*(towp+2*j+1)==y)
{
flag=true;
j=130;
}
}
if(!flag)
{
for(int k=100;k<i;k++)
{
if(*(test+2*k)==x&&*(test+2*k+1)==y)
{
flag=true;
k=i;
}
}
}
if(!flag)
{
*(test+2*i)=x;
*(test+2*i+1)=y;
}
i++;
}
}
while(i<300)
{
x=(int)(rand()%200)+int(100*1.732)+1;
y=(int)(rand()%200)+100;
BOOL flag=false;
if((x-100-int(100*1.732)-1)*(x-100-int(100*1.732)-1)+(y-200)*(y-200)<10000)
{
for(int j=0;j<150;j++)
{
if(*(threep+2*j)==x&&*(threep+2*j+1)==y)
{
flag=true;
j=150;
}
}
if(!flag)
{
for(int k=200;k<i;k++)
{
if(*(test+2*k)==x&&*(test+2*k+1)==y)
{
flag=true;
k=i;
}
}
}
if(!flag)
{
*(test+2*i)=x;
*(test+2*i+1)=y;
}
i++;
}
}
ff4=true;
}
////////////////////////////////////////////////////////
flag5=true;
CRect rectldj;
GetDlgItem(IDC_STATIC1)->GetWindowRect(rectldj);ScreenToClient(rectldj);
InvalidateRect(rectldj,true);
GetDlgItem(IDC_STATIC2)->GetWindowRect(rectldj);ScreenToClient(rectldj);
strcpy(m_n.mychar,"產生測試第一類的點數: 100");
strcpy(m_n1.mychar,"產生測試第二類的點數: 100");
strcpy(m_n2.mychar,"產生測試第三類的點數: 100");
InvalidateRect(rectldj,true);
}
void CMyDlg::OnClass31()
{
// TODO: Add your command handler code here
m_l.ModifyStyle(WS_VISIBLE,LVS_OWNERDRAWFIXED);
int count=0;
int i;
for(i=0;i<100;i++)
{
int c1,c2,c3;
int j=1;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -