⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 最近邻法分类器dlg.cpp

📁 本程序是一个最近邻分类算法的演示程序
💻 CPP
📖 第 1 页 / 共 4 页
字号:
				         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 + -