?? 最近鄰法分類器dlg.cpp
字號:
// 最近鄰法分類器Dlg.cpp : implementation file
//
#include "stdafx.h"
#include "最近鄰法分類器.h"
#include "最近鄰法分類器Dlg.h"
#include "Dialogk.h"
#include "Dialogkk.h"
#include "Dialogs1.h"
#include "Dialogs3.h"
#include "Dialog34.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyDlg dialog
CMyDlg::CMyDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMyDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CMyDlg)
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CMyDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMyDlg)
DDX_Control(pDX, IDC_LIST2, m_l);
DDX_Control(pDX, IDC_STATICC4, m_c4);
DDX_Control(pDX, IDC_STATICN2, m_n2);
DDX_Control(pDX, IDC_STATICN1, m_n1);
DDX_Control(pDX, IDC_STATICN, m_n);
DDX_Control(pDX, IDC_STATICk3, m_k3);
DDX_Control(pDX, IDC_STATICk2, m_k2);
DDX_Control(pDX, IDC_STATICk1, m_k1);
DDX_Control(pDX, IDC_STATICC3, m_c3);
DDX_Control(pDX, IDC_STATICC2, m_c2);
DDX_Control(pDX, IDC_STATICC1, m_c1);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
//{{AFX_MSG_MAP(CMyDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_ERASEBKGND()
ON_WM_DRAWITEM()
ON_WM_MEASUREITEM()
ON_WM_MOUSEMOVE()
ON_WM_NCMOUSEMOVE()
ON_COMMAND(ID_Class11, OnClass11)
ON_COMMAND(ID_Class12, OnClass12)
ON_COMMAND(ID_Class13, OnClass13)
ON_COMMAND(ID_Class21, OnClass21)
ON_COMMAND(ID_Class31, OnClass31)
ON_COMMAND(ID_Class32, OnClass32)
ON_COMMAND(ID_Class33, OnClass33)
ON_COMMAND(ID_Class42, OnClass42)
ON_COMMAND(ID_Class43, OnClass43)
ON_COMMAND(ID_Class44, OnClass44)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyDlg message handlers
BOOL CMyDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
int cx, cy;
HDC dc = ::GetDC(NULL);
cx = GetDeviceCaps(dc,HORZRES) +
GetSystemMetrics(SM_CXBORDER);
cy = GetDeviceCaps(dc,VERTRES) +
GetSystemMetrics(SM_CYBORDER)-20;
::ReleaseDC(0,dc); //
::SetWindowPos(m_hWnd, HWND_TOPMOST,
-(GetSystemMetrics(SM_CXBORDER)+1),
-(GetSystemMetrics(SM_CYBORDER)+1),
cx+1,cy+1, SWP_NOZORDER);
// TODO: Add extra initialization here
m_mmenu.AttachMenu(GetMenu()->GetSafeHmenu());
mybitmap.LoadBitmap(IDB_BITMAP1);
CRect rect1,rect2,rect,rect3;GetClientRect(rect);
GetDlgItem(IDC_STATIC1)->GetWindowRect(rect1);ScreenToClient(rect1);
rect1.left=rect.left+20;
rect1.right=rect.right-370;
rect1.top=rect.top+20;
rect1.bottom =rect.bottom-20;
GetDlgItem(IDC_STATIC1)->MoveWindow(rect1,true);
rect2.left=rect1.right+20;
rect2.right=rect.right-20;
rect2.top=rect.top+20;
rect2.bottom =rect1.top+rect1.Height()/2-20;
GetDlgItem(IDC_STATIC2)->MoveWindow(rect2,true);
rect3.left=rect1.right+20;
rect3.right=rect.right-20;
rect3.bottom=rect.bottom-20;;
rect3.top =rect1.bottom-rect1.Height()/2+20;
GetDlgItem(IDC_STATIC3)->MoveWindow(rect3,true);
CRect rects1,rects2,rects3,rects4,rectn1,rectn2;
GetDlgItem(IDC_STATICN)->GetWindowRect(rects1);ScreenToClient(rects1);
rects1.left=rect2.left+50;
rects1.right=rect2.right-50;
rects1.top =rect2.top+50;
rects1.bottom=rects1.top+20;
GetDlgItem(IDC_STATICN)->MoveWindow(rects1,true);
rectn1.left=rect2.left+50;
rectn1.right=rect2.right-50;
rectn1.top =rects1.bottom+20;
rectn1.bottom=rectn1.top+20;
GetDlgItem(IDC_STATICN1)->MoveWindow(rectn1,true);
rectn2.left=rect2.left+50;
rectn2.right=rect2.right-50;
rectn2.top =rectn1.bottom+20;
rectn2.bottom=rectn2.top+20;
GetDlgItem(IDC_STATICN2)->MoveWindow(rectn2,true);
rects2.left=rect2.left+50;
rects2.right=rect2.right-50;
rects2.top =rectn2.bottom+20;
rects2.bottom=rects2.top+20;
GetDlgItem(IDC_STATICk1)->MoveWindow(rects2,true);
rects3.left=rect2.left+50;
rects3.right=rect2.right-50;
rects3.top =rects2.bottom+20;
rects3.bottom=rects3.top+20;
GetDlgItem(IDC_STATICk2)->MoveWindow(rects3,true);
rects4.left=rect2.left+50;
rects4.right=rect2.right-50;
rects4.top =rects3.bottom+20;
rects4.bottom=rects4.top+20;
GetDlgItem(IDC_STATICk3)->MoveWindow(rects4,true);
CRect rectk1,rectk2,rectk3,rectk4;
rectk1.left=rect3.left+50;
rectk1.right=rect3.right-50;
rectk1.top =rect3.top+80;
rectk1.bottom=rectk1.top+20;
GetDlgItem(IDC_STATICC1)->MoveWindow(rectk1,true);
rectk2.left=rect2.left+50;
rectk2.right=rect2.right-50;
rectk2.top =rectk1.bottom+20;
rectk2.bottom=rectk2.top+20;
GetDlgItem(IDC_STATICC2)->MoveWindow(rectk2,true);
rectk3.left=rect2.left+50;
rectk3.right=rect2.right-50;
rectk3.top =rectk2.bottom+20;
rectk3.bottom=rectk3.top+20;
GetDlgItem(IDC_STATICC3)->MoveWindow(rectk3,true);
rectk4.left=rect2.left+50;
rectk4.right=rect2.right-50;
rectk4.top =rectk3.bottom+20;
rectk4.bottom=rectk4.top+20;
GetDlgItem(IDC_STATICC4)->MoveWindow(rectk4,true);
GetDlgItem(IDC_LIST2)->GetWindowRect(rectk4);ScreenToClient(rectk4);
int temp1=rectk4.Width();
int temp2=rectk4.Height();
rectk4.left=rect2.left+20;
rectk4.right=rectk4.left+temp1;//rect2.right-10;
rectk4.top =rectk1.bottom+20;
rectk4.bottom=rectk4.top+temp2;
GetDlgItem(IDC_LIST2)->MoveWindow(rectk4,true);
m_l.SetExtendedStyle (LVS_OWNERDRAWFIXED);
CRect ClientRect;
GetDlgItem(IDC_LIST2)->GetClientRect(&ClientRect);
m_l.InsertColumn (0, " ");
m_l.InsertColumn (1, "1,2類");
m_l.InsertColumn (2, "1,3類");
m_l.InsertColumn (3, "2,3類");
m_l.SetColumnWidth (0, ClientRect.Width() / 4);
m_l.SetColumnWidth (1, ClientRect.Width() / 4);
m_l.SetColumnWidth (2, ClientRect.Width() / 4);
m_l.SetColumnWidth (3, LVSCW_AUTOSIZE_USEHEADER+80);
for(int i=0;i<14;i++)
{
m_l.InsertItem (i, " ");
}
flag1=false;flag2=false;flag3=false,flag4=false,flag5=false;f1=false;f2=false;f3=false;ff1=false;ff2=false;ff3=false;ff4=false;Seticon();
return TRUE; // return TRUE unless you set the focus to a control
}
void CMyDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CMyDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CMyDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
BOOL CMyDlg::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
CRect rect;
GetClientRect(rect);
//////////////////////////////////////////////////////
CDC memdc;
BITMAP bm1;
mybitmap.GetObject(sizeof(BITMAP),&bm1);
memdc.CreateCompatibleDC(pDC);
CBitmap* oldbitmap=memdc.SelectObject(&mybitmap);
int wide=rect.Width()/4;
int mheight=rect.Height()/4;
for (int j=0;j<4;j++)
{
for(int i=0;i<4;i++)
{
pDC->StretchBlt(rect.left,rect.top,wide,mheight,&memdc,0,0,bm1.bmWidth,bm1.bmHeight,SRCCOPY);
rect.left+= wide;
}
rect.left-=wide*4;
rect.top+=mheight;
}
CRect rectp;
CPen *pOldPen;
GetDlgItem(IDC_STATIC1)->GetWindowRect(rectp);ScreenToClient(rectp);
pDC->FillSolidRect(rectp,RGB(255,255,255));
CPen mypen1(PS_SOLID,1,RGB(0,0,0));
CPen mypen2(PS_SOLID,0,RGB(0,0,255));
CPen mypen21(PS_DOT ,0,RGB(50,50,125));
CPen mypen3(PS_SOLID,0,RGB(255,0,0));
CPen mypen31(PS_DOT,0,RGB(125,50,50));
CPen mypen4(PS_SOLID,0,RGB(0,255,0));
CPen mypen41(PS_DOT,0,RGB(50,125,50));
CPen mypen5(PS_SOLID,0,RGB(0,0,0));
pOldPen=pDC->SelectObject(&mypen1);
pDC->MoveTo(rectp.left+20, rectp.bottom-30);
pDC->LineTo(rectp.left+620, rectp.bottom-30);
pDC->LineTo(rectp.left+610, rectp.bottom-25);
pDC->MoveTo(rectp.left+620, rectp.bottom-30);
pDC->LineTo(rectp.left+610, rectp.bottom-35);
pDC->MoveTo(rectp.left+20, rectp.bottom-30);
pDC->LineTo(rectp.left+20, rectp.bottom-640);
pDC->LineTo(rectp.left+25, rectp.bottom-630);
pDC->MoveTo(rectp.left+20, rectp.bottom-640);
pDC->LineTo(rectp.left+15, rectp.bottom-630);
if(flag1)
{
pDC->SelectObject(&mypen21);
CRect rect1(rectp.left+20+0,rectp.bottom-30-400,rectp.left+20+200,rectp.bottom-30-200);pDC->Ellipse(rect1);
pDC->SelectObject(&mypen2);
for(int i1=0;i1<120;i1++)
{
CRect rect(rectp.left+20+*(onep+2*i1)-1,rectp.bottom-30-*(onep+2*i1+1)-1,rectp.left+20+*(onep+2*i1)+1,rectp.bottom-30-*(onep+2*i1+1)+1);
pDC->Ellipse(rect);
}
CRect rectp,rcIcon1;
GetDlgItem(IDC_STATICk1)->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(),
Sicon2,
DSS_NORMAL|DST_ICON ,
(CBrush*)NULL);
}
if(flag2)
{
pDC->SelectObject(&mypen31);
CRect rect1(rectp.left+20+0,rectp.bottom-30-200,rectp.left+20+200,rectp.bottom-30);pDC->Ellipse(rect1);
pDC->SelectObject(&mypen3);
for(int i11=0;i11<130;i11++)
{
CRect rect(rectp.left+20+*(towp+2*i11)-1,rectp.bottom-30-*(towp+2*i11+1)-1,rectp.left+20+*(towp+2*i11)+1,rectp.bottom-30-*(towp+2*i11+1)+1);
pDC->Ellipse(rect);
}
CRect rectp,rcIcon1;
GetDlgItem(IDC_STATICk2)->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(),
Sicon3,
DSS_NORMAL|DST_ICON ,
(CBrush*)NULL);
}
if(flag3)
{
pDC->SelectObject(&mypen41);
CRect rect1(rectp.left+20+int(100*1.732)+1,rectp.bottom-30-300,rectp.left+20+int(100*1.732)+201,rectp.bottom-30-100);pDC->Ellipse(rect1);
pDC->SelectObject(&mypen4);
for(int i111=0;i111<150;i111++)
{
CRect rect(rectp.left+20+*(threep+2*i111)-1,rectp.bottom-30-*(threep+2*i111+1)-1,rectp.left+20+*(threep+2*i111)+1,rectp.bottom-30-*(threep+2*i111+1)+1);
pDC->Ellipse(rect);
}
CRect rectp,rcIcon1;
GetDlgItem(IDC_STATICk3)->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(),
Sicon4,
DSS_NORMAL|DST_ICON ,
(CBrush*)NULL);
}
if(flag5)
{
pDC->SelectObject(&mypen5);
for(int i1111=0;i1111<300;i1111++)
{
CRect rect(rectp.left+20+*(test+2*i1111)-1,rectp.bottom-30-*(test+2*i1111+1)-1,rectp.left+20+*(test+2*i1111)+1,rectp.bottom-30-*(test+2*i1111+1)+1);
pDC->Ellipse(rect);
}
CRect rectp,rcIcon1;
GetDlgItem(IDC_STATICN)->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);
GetDlgItem(IDC_STATICN1)->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,
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -