📄 dialogt.cpp
字号:
// DialogT.cpp : implementation file
//
#include "stdafx.h"
#include "线性分类器.h"
#include "DialogT.h"
#include "线性分类器Dlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include"MyProgressCtrl.h"
/////////////////////////////////////////////////////////////////////////////
// CDialogT dialog
CDialogT::CDialogT(CWnd* pParent /*=NULL*/)
: CDialog(CDialogT::IDD, pParent)
{
//{{AFX_DATA_INIT(CDialogT)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CDialogT::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDialogT)
DDX_Control(pDX, IDC_STATIC1, m_s);
DDX_Control(pDX, IDOK, m_bo);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDialogT, CDialog)
//{{AFX_MSG_MAP(CDialogT)
ON_WM_ERASEBKGND()
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDialogT message handlers
BOOL CDialogT::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
mybitmap.LoadBitmap(IDB_BITMAP1);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CDialogT::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);
pDC->StretchBlt(rect.left,rect.top,rect.Width(),rect.Height(),&memdc,0,0,bm1.bmWidth,bm1.bmHeight,SRCCOPY);
return false;
}
void CDialogT::OnOK()
{
// TODO: Add extra validation here
CMyProgressCtrl myprogress;
AfxGetApp()->BeginWaitCursor();
GetDlgItem(IDOK)->EnableWindow(false);
CRect rect,rect1;
GetClientRect(rect);
int temp=rect.left+rect.Width()/2;
rect.left=temp-150;
rect.right=temp+150;
GetDlgItem(IDOK)->GetWindowRect(rect1);
ScreenToClient(rect1);
rect.top=rect1.top-50;
rect.bottom=rect.top+20;
myprogress.Create(WS_CHILD|WS_VISIBLE,rect,this,1820);
myprogress.SetRange(0,200);
CMyDlg* pp1=(CMyDlg*)GetParent();
int t=0;
double count;
double z,xt,yt,w1,w2,w3;
for(int i=0;i<200;i++)
{
if((i%10)==0)
{
myprogress.SetPos(i);
Sleep(100);
}
if(i<100)
{
xt=((double)(*(onetp+2*i)))/10;
yt=((double)(*(onetp+2*i+1)))/10;
w1=pp1->w1;
w2=pp1->w2;
w3=pp1->w4;
if(w2>0)
{
z=w1*xt+w2*yt+w3;
}
else
{
z=-w1*xt-w2*yt-w3;
}
if(z<=0)
{
t++;
}
}
else
{
if(i<200)
{
xt=((double)(*(towtp+2*(i-100))))/10;
yt=((double)(*(towtp+2*(i-100)+1)))/10;
w1=pp1->w1;
w2=pp1->w2;
w3=pp1->w4;
if(w2>0)
{
z=w1*xt+w2*yt+w3;
}
else
{
z=-w1*xt-w2*yt-w3;
}
if(z>=0)
{
t++;
}
}
}
}
myprogress.SetPos(200);
count=((double)(200-t))/200;
int intn=int(count*100);
CString temp1;
temp1.Format("%d", intn);
strcpy(m_s.mychar,"识别率: ");
strcat(m_s.mychar,temp1);
temp1.Empty( );
int dot=int(count*100000-intn*1000+0.5);
strcat(m_s.mychar,".");
temp1.Format("%d", dot);
strcat(m_s.mychar,temp1);
strcat(m_s.mychar,"%");
CRect rectz;
GetDlgItem(IDC_STATIC1)->GetWindowRect(rectz);ScreenToClient(rectz);
InvalidateRect(rectz,true);
AfxGetApp()->EndWaitCursor();
//CDialog::OnOK();
}
void CDialogT::OnClose()
{
// TODO: Add your message handler code here and/or call default
CMyDlg* pp1=(CMyDlg*)GetParent();
pp1->m_b6.down=false;
pp1->m_b6.Invalidate();
CDialog::OnClose();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -