📄 zfwdlg.cpp
字号:
// zfwDlg.cpp : implementation file
//
#include "stdafx.h"
#include "zfw.h"
#include "zfwDlg.h"
#include "Windows.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()
/////////////////////////////////////////////////////////////////////////////
// CZfwDlg dialog
CZfwDlg::CZfwDlg(CWnd* pParent /*=NULL*/)
: CDialog(CZfwDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CZfwDlg)
s1[0] = _T("");
s1[1] = _T("");
s1[2] = _T("");
s1[3] = _T("");
s1[4] = _T("");
s1[5] = _T("");
s1[6] = _T("");
s1[7] = _T("");
s2[0] = 0;
s2[1] = 0;
s2[2] = 0;
s2[3] = 0;
s2[4] = 0;
s2[5] = 0;
s2[6] = 0;
s2[7] = 0;
s3[0] = 0;
s3[1] = 0;
s3[2] = 0;
s3[3] = 0;
s3[4] = 0;
s3[5] = 0;
s3[6] = 0;
s3[7] = 0;
s4[0] = 0;
s4[1] = 0;
s4[2] = 0;
s4[3] = 0;
s4[4] = 0;
s4[5] = 0;
s4[6] = 0;
s4[7] = 0;
m_15 = 0;
m_25 = 0;
m_35 = 0;
m_45 = 0;
m_55 = 0;
m_65 = 0;
m_75 = 0;
m_85 = 0;
t[0] = 128;
t[1] = 64;
t[2] = 32;
t[3] = 16;
t[4] = 8;
t[5] = 4;
t[6] = 2;
t[7] = 1;
k = 0;
m = 0;
i = 0;
x = 0;
y = 0;
z = 0;
u = 0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CZfwDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CZfwDlg)
DDX_Text(pDX, IDC_EDIT11, s1[0]);
DDX_Text(pDX, IDC_EDIT21, s1[1]);
DDX_Text(pDX, IDC_EDIT31, s1[2]);
DDX_Text(pDX, IDC_EDIT41, s1[3]);
DDX_Text(pDX, IDC_EDIT51, s1[4]);
DDX_Text(pDX, IDC_EDIT61, s1[5]);
DDX_Text(pDX, IDC_EDIT71, s1[6]);
DDX_Text(pDX, IDC_EDIT81, s1[7]);
DDX_Text(pDX, IDC_EDIT12, s2[0]);
DDX_Text(pDX, IDC_EDIT13, s3[0]);
DDX_Text(pDX, IDC_EDIT14, s4[0]);
DDX_Text(pDX, IDC_EDIT15, m_15);
DDX_Text(pDX, IDC_EDIT23, s3[1]);
DDX_Text(pDX, IDC_EDIT22, s2[1]);
DDX_Text(pDX, IDC_EDIT24, s4[1]);
DDX_Text(pDX, IDC_EDIT25, m_25);
DDX_Text(pDX, IDC_EDIT32, s2[2]);
DDX_Text(pDX, IDC_EDIT33, s3[2]);
DDX_Text(pDX, IDC_EDIT34, s4[2]);
DDX_Text(pDX, IDC_EDIT35, m_35);
DDX_Text(pDX, IDC_EDIT42, s2[3]);
DDX_Text(pDX, IDC_EDIT43, s3[3]);
DDX_Text(pDX, IDC_EDIT44, s4[3]);
DDX_Text(pDX, IDC_EDIT45, m_45);
DDX_Text(pDX, IDC_EDIT52, s2[4]);
DDX_Text(pDX, IDC_EDIT53, s3[4]);
DDX_Text(pDX, IDC_EDIT54, s4[4]);
DDX_Text(pDX, IDC_EDIT55, m_55);
DDX_Text(pDX, IDC_EDIT62, s2[5]);
DDX_Text(pDX, IDC_EDIT63, s3[5]);
DDX_Text(pDX, IDC_EDIT64, s4[5]);
DDX_Text(pDX, IDC_EDIT65, m_65);
DDX_Text(pDX, IDC_EDIT72, s2[6]);
DDX_Text(pDX, IDC_EDIT73, s3[6]);
DDX_Text(pDX, IDC_EDIT74, s4[6]);
DDX_Text(pDX, IDC_EDIT75, m_75);
DDX_Text(pDX, IDC_EDIT82, s2[7]);
DDX_Text(pDX, IDC_EDIT83, s3[7]);
DDX_Text(pDX, IDC_EDIT84, s4[7]);
DDX_Text(pDX, IDC_EDIT85, m_85);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CZfwDlg, CDialog)
//{{AFX_MSG_MAP(CZfwDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CZfwDlg message handlers
BOOL CZfwDlg::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
return TRUE; // return TRUE unless you set the focus to a control
}
void CZfwDlg::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 CZfwDlg::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 CZfwDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CZfwDlg::OnButton1()
{UpdateData(true);
KillTimer(1);
for(k=0;k<8;k++)
{m=rand()%8;
m++;
for(i=0;i<k;i++)
{while(pcb1[i]==m)
{m=rand()%8;
m++;
i=0;
}
}
pcb1[k]=m;
}
for(k=0;k<8;k++)
{m=1+rand()%128;
pcb2[k]=m;
}
m_15=pcb2[0];
m_25=pcb2[1];
m_35=pcb2[2];
m_45=pcb2[3];
m_55=pcb2[4];
m_65=pcb2[5];
m_75=pcb2[6];
m_85=pcb2[7];
s3[0]=0;
s3[1]=0;
s3[2]=0;
s3[3]=0;
s3[4]=0;
s3[5]=0;
s3[6]=0;
s3[7]=0;
s4[0]=0;
s4[1]=0;
s4[2]=0;
s4[3]=0;
s4[4]=0;
s4[5]=0;
s4[6]=0;
s4[7]=0;
s2[0]=0;
s2[1]=0;
s2[2]=0;
s2[3]=0;
s2[4]=0;
s2[5]=0;
s2[6]=0;
s2[7]=0;
s1[0]=_T("");
s1[1]=_T("");
s1[2]=_T("");
s1[3]=_T("");
s1[4]=_T("");
s1[5]=_T("");
s1[6]=_T("");
s1[7]=_T("");
i=8;
js=1;
UpdateData(false);
}
void CZfwDlg::OnTimer(UINT nIDEvent)
{UpdateData(true);
for(k=0;k<8;k++)
{if(pcb1[0]==s4[k])
{if(s3[k]>t[k])
{s1[k]="runing";
s2[k]+=t[k];
s3[k]-=t[k];
}
else
{s2[k]+=s3[k];
s3[k]=0;
s1[k]="end";
}
}
else
if(s3[k]==0)
s1[k]="end";
else
s1[k]="ready";
}
/*实现进程队列修改和服务未完成进程队列数的修改*/
m=pcb1[0];
z=s3[m-1];
if(z==0)
{for(x=0;x<i-1;x++)
pcb1[x]=pcb1[x+1];
pcb1[x]=0;
i--;
}
else
{for(y=0;y<i-1;y++)
pcb1[y]=pcb1[y+1];
pcb1[y]=m;
}
if(i==0||js==1)
KillTimer(1);
// TODO: Add your control notification handler code here
UpdateData(false);
CDialog::OnTimer(nIDEvent);
}
void CZfwDlg::OnButton2()
{ if(i==8)
{UpdateData(true);
s4[0]=1;
s4[1]=2;
s4[2]=3;
s4[3]=4;
s4[4]=5;
s4[5]=6;
s4[6]=7;
s4[7]=8;
s3[0]=pcb2[0];
s3[1]=pcb2[1];
s3[2]=pcb2[2];
s3[3]=pcb2[3];
s3[4]=pcb2[4];
s3[5]=pcb2[5];
s3[6]=pcb2[6];
s3[7]=pcb2[7];
UpdateData(false);}
if(js==0)
js=1;
else
js=0;
SetTimer(1,200,NULL);
}
void CZfwDlg::OnButton3()
{PostQuitMessage(0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -