📄 yilufadlg.cpp
字号:
// yilufaDlg.cpp : implementation file
//
#include "stdafx.h"
#include "yilufa.h"
#include "yilufaDlg.h"
#include "3DTextButton.h"
#include "math.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
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()
/////////////////////////////////////////////////////////////////////////////
// CYilufaDlg dialog
CYilufaDlg::CYilufaDlg(CWnd* pParent /*=NULL*/)
: CDialog(CYilufaDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CYilufaDlg)
m_11 = 0;
m_12 = 0;
m_13 = 0;
m_14 = 0;
m_21 = 0;
m_22 = 0;
m_23 = 0;
m_24 = 0;
m_31 = 0;
m_32 = 0;
m_33 = 0;
m_34 = 0;
m_41 = 0;
m_42 = 0;
m_43 = 0;
m_44 = 0;
m_51 = 0;
m_52 = 0;
m_53 = 0;
m_54 = 0;
m_61 = 0;
m_62 = 0;
m_63 = 0;
m_64 = 0;
m_71 = 0;
m_72 = 0;
m_73 = 0;
m_74 = 0;
m_81 = 0;
m_82 = 0;
m_83 = 0;
m_84 = 0;
m_StepLong = 3;
m_ZhanTin = TRUE;
m_NewHead = 0;
m_NewLast = 0;
m_NewHundred = 0;
m_NewNumber = 0;
m_NewTen = 0;
m_LawLong = 8;
m_bMoveFlag = FALSE;
bLogarithmicFlag = TRUE;
bCombinationFlag = TRUE;
bOneFlag = TRUE;
m_Infromation = _T("");
bLongOrShort = TRUE;
bAddFlag=FALSE;
bTwoToTwo=TRUE;
m_Rock = _T("期");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
Record=NULL;
pThread1=NULL;
pThread=NULL;
bModifyFlag=FALSE;
for(int k=0;k<8;k++)
for(int l=0;l<4;l++)
{
Number[k][l]=0;
}
for(k=0;k<4;k++)
{
for(int l=1;l<11;l++) m_OutNumber[k][l]=88;
m_OutNumber[k][0]=0;
m_OutNumber[k][11]=0;
}
for(k=0;k<200;k++)
{
Number[k][5]=0;
}
b_ExitFlag=FALSE;
bFinishFlag=TRUE;
m_bStopFlag=FALSE; //TO control the stop button
EmptyPiont=0;
if(!LoadData()) AfxMessageBox("装入数据失败");
else
{
EndPiont=EmptyPiont-1;
BeginPiont=EndPiont-7;
CurrentPiont=EndPiont;
}
////////
MoveY=0;
m_CurrentLaw=0;
gls=0;
m_ToWork.text="分析数据";
m_ToSaveData.text="保存号码";
m_PriButton.text="上期号码";
m_NextButton.text="下期号码";
m_ModifyButton.text="修改号码";
m_AddNew.text="增加号码";
m_StopButton.text="暂停分析";
m_ShowLastResultButton.text="查询规律";
m_Ok.text="退出";
m_ShowLastResult.text="显示号码";
}
void CYilufaDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CYilufaDlg)
DDX_Control(pDX, IDC_SCROLLB, m_ScrollB);
DDX_Control(pDX, IDOK, m_Ok);
DDX_Control(pDX, IDC_SHOWLASTRESULT, m_ShowLastResult);
DDX_Control(pDX, IDC_SHOWLAWBUTTON, m_ShowLastResultButton);
DDX_Control(pDX, IDC_TOSAVEDATA, m_ToSaveData);
DDX_Control(pDX, IDC_PREBUTTON, m_PriButton);
DDX_Control(pDX, IDC_NEXTBUTTON, m_NextButton);
DDX_Control(pDX, IDC_MODIFYBUTTON, m_ModifyButton);
DDX_Control(pDX, IDC_ADDNEW, m_AddNew);
DDX_Control(pDX, IDC_CMPPROGRESS, m_CmpProgress);
DDX_Control(pDX, IDC_TOWORK, m_ToWork);
DDX_Control(pDX, IDC_STOP, m_StopButton);
DDX_Control(pDX, IDC_PRO, m_Progress);
DDX_Text(pDX, IDC_11, m_11);
DDX_Text(pDX, IDC_12, m_12);
DDX_Text(pDX, IDC_13, m_13);
DDX_Text(pDX, IDC_14, m_14);
DDX_Text(pDX, IDC_21, m_21);
DDX_Text(pDX, IDC_22, m_22);
DDX_Text(pDX, IDC_23, m_23);
DDX_Text(pDX, IDC_24, m_24);
DDX_Text(pDX, IDC_31, m_31);
DDX_Text(pDX, IDC_32, m_32);
DDX_Text(pDX, IDC_33, m_33);
DDX_Text(pDX, IDC_34, m_34);
DDX_Text(pDX, IDC_41, m_41);
DDX_Text(pDX, IDC_42, m_42);
DDX_Text(pDX, IDC_43, m_43);
DDX_Text(pDX, IDC_44, m_44);
DDX_Text(pDX, IDC_51, m_51);
DDX_Text(pDX, IDC_52, m_52);
DDX_Text(pDX, IDC_53, m_53);
DDX_Text(pDX, IDC_54, m_54);
DDX_Text(pDX, IDC_61, m_61);
DDX_Text(pDX, IDC_62, m_62);
DDX_Text(pDX, IDC_63, m_63);
DDX_Text(pDX, IDC_64, m_64);
DDX_Text(pDX, IDC_71, m_71);
DDX_Text(pDX, IDC_72, m_72);
DDX_Text(pDX, IDC_73, m_73);
DDX_Text(pDX, IDC_74, m_74);
DDX_Text(pDX, IDC_81, m_81);
DDX_Text(pDX, IDC_82, m_82);
DDX_Text(pDX, IDC_83, m_83);
DDX_Text(pDX, IDC_84, m_84);
DDX_Text(pDX, IDC_STEPLONG, m_StepLong);
DDX_Check(pDX, IDC_ZANTIN, m_ZhanTin);
DDX_Text(pDX, IDC_NEWHEAD, m_NewHead);
DDV_MinMaxUInt(pDX, m_NewHead, 0, 9);
DDX_Text(pDX, IDC_NEWL, m_NewLast);
DDV_MinMaxUInt(pDX, m_NewLast, 0, 9);
DDX_Text(pDX, IDC_NEWHUNDRED, m_NewHundred);
DDV_MinMaxUInt(pDX, m_NewHundred, 0, 9);
DDX_Text(pDX, IDC_NEWNUMBER, m_NewNumber);
DDX_Text(pDX, IDC_NEWTEN, m_NewTen);
DDV_MinMaxUInt(pDX, m_NewTen, 0, 9);
DDX_Text(pDX, IDC_LAWLONG, m_LawLong);
DDX_Check(pDX, IDC_MOVEAREA, m_bMoveFlag);
DDX_Check(pDX, IDC_LOGARITHMIC, bLogarithmicFlag);
DDX_Check(pDX, IDC_COMBINATION, bCombinationFlag);
DDX_Check(pDX, IDC_ONEFLAG, bOneFlag);
DDX_Text(pDX, IDC_INFROMATION, m_Infromation);
DDX_Check(pDX, IDC_LONGORSHORT, bLongOrShort);
DDX_Text(pDX, IDC_ROCK, m_Rock);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CYilufaDlg, CDialog)
//{{AFX_MSG_MAP(CYilufaDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_TOWORK, OnTowork)
ON_BN_CLICKED(IDC_STOP, OnStop)
ON_BN_CLICKED(IDC_ADDNEW, OnAddnew)
ON_BN_CLICKED(IDC_TOSAVEDATA, OnTosavedata)
ON_BN_CLICKED(IDC_SHOWLASTRESULT, OnShowlastresult)
ON_BN_CLICKED(IDC_ZANTIN, OnZantin)
ON_EN_CHANGE(IDC_NEWNUMBER, OnChangeNewnumber)
ON_BN_CLICKED(IDC_MODIFYBUTTON, OnModifyData)
ON_EN_KILLFOCUS(IDC_NEWNUMBER, OnKillfocusNewnumber)
ON_EN_CHANGE(IDC_NEWHEAD, OnChangeNewhead)
ON_EN_CHANGE(IDC_NEWHUNDRED, OnChangeNewhundred)
ON_EN_CHANGE(IDC_NEWTEN, OnChangeNewten)
ON_EN_CHANGE(IDC_NEWL, OnChangeNewl)
ON_BN_CLICKED(IDC_PREBUTTON, OnPrebutton)
ON_BN_CLICKED(IDC_NEXTBUTTON, OnNextbutton)
ON_BN_CLICKED(IDC_MOVEAREA, OnMovearea)
ON_BN_CLICKED(IDC_SHOWLAWBUTTON, OnShowlawbutton)
ON_WM_VSCROLL()
ON_BN_CLICKED(IDC_LOGARITHMIC, OnLogarithmic)
ON_EN_KILLFOCUS(IDC_STEPLONG, OnKillfocusSteplong)
ON_EN_KILLFOCUS(IDC_LAWLONG, OnKillfocusLawlong)
ON_BN_CLICKED(IDC_COMBINATION, OnCombination)
ON_BN_CLICKED(IDC_ONEFLAG, OnOneflag)
ON_BN_CLICKED(IDC_LONGORSHORT, OnLongorshort)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CYilufaDlg message handlers
BOOL CYilufaDlg::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
// TODO: Add extra initialization here
m_ToWork.SetFocus();
GetDlgItem(IDC_NEWNUMBER)->EnableWindow(FALSE);
GetDlgItem(IDC_NEWHEAD)->EnableWindow(FALSE);
GetDlgItem(IDC_NEWHUNDRED)->EnableWindow(FALSE);
GetDlgItem(IDC_NEWTEN)->EnableWindow(FALSE);
GetDlgItem(IDC_NEWL)->EnableWindow(FALSE);
return FALSE; // return TRUE unless you set the focus to a control
}
void CYilufaDlg::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 CYilufaDlg::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();
}
////////
//if(gls>0) RollView();
///
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CYilufaDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CYilufaDlg::OnTowork()
{
UpdateData(TRUE);
m_bStopFlag=FALSE;
m_OutNumber[0][0]=0;
m_OutNumber[1][0]=0;
m_OutNumber[2][0]=0;
m_OutNumber[3][0]=0;
gls=0;
MoveY=0;
m_StopButton.text="暂停分析";
m_ToWork.text="重新分析";
GetDlgItem(IDC_TOWORK)->EnableWindow(FALSE);
GetDlgItem(IDC_LAWLONG)->EnableWindow(FALSE);
GetDlgItem(IDC_STOP)->SetFocus();
if(!bLongOrShort)
{
BeginPiont=EndPiont-m_LawLong*4-2;
}
bFinishFlag=TRUE;
pThread=AfxBeginThread(FindLaw,this);
//pThread1=CreateThread(NULL,0,ShowStep,this,0,&dw);
GetDlgItem(IDC_TOWORK)->EnableWindow(FALSE);
UpdateData(FALSE);
}
UINT CYilufaDlg::CmpNumber(UINT SoureFirstRank, UINT SoureFirstLine, UINT SoureSecondRank, UINT SoureSecondLine, UINT DestationRank, UINT DestationLine, UINT *Step,LPVOID pParam)
{
CYilufaDlg* dlg=(CYilufaDlg*)pParam;
int m_Step=1;
UINT sfr,ssr,dr;
sfr=SoureFirstRank;
ssr=SoureSecondRank;
dr=DestationRank;
UINT m_MaxRank;
m_MaxRank=sfr<ssr?ssr:sfr;
m_MaxRank=m_MaxRank<dr?dr:m_MaxRank;
m_MaxRank=EndPiont-m_MaxRank+1;
if(bLongOrShort)
{
for(;m_Step*m_StepLong<=m_MaxRank;m_Step++,(*Step)=1)
{
if((m_MaxRank%m_Step)!=0) continue;
for(sfr=SoureFirstRank+m_Step,ssr=SoureSecondRank+m_Step,dr=DestationRank+m_Step;(sfr<=EndPiont)&&(ssr<=EndPiont)&&(dr<=EndPiont);sfr+=m_Step,ssr+=m_Step,dr+=m_Step)
{
if((Number[sfr][SoureFirstLine]+Number[ssr][SoureSecondLine])>=10)
{
if((Number[sfr][SoureFirstLine]+Number[ssr][SoureSecondLine]-10)==Number[dr][DestationLine])
{
(*Step)++;
}
else if(bLogarithmicFlag)
{
if(((Number[sfr][SoureFirstLine]+Number[ssr][SoureSecondLine]-10)-5==Number[dr][DestationLine])||((Number[sfr][SoureFirstLine]+Number[ssr][SoureSecondLine]-10)+5==Number[dr][DestationLine]))
{
(*Step)++;
}
else break;
}
else break;
}
else
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -