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

📄 mylistview.cpp

📁 这是软件工程的关于模拟进程调度的课程论文
💻 CPP
字号:
// MyListView.cpp : implementation file
//

#include "stdafx.h"
#include "processmanager.h"
#include "MyListView.h"
#include "PCB.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMyListView

IMPLEMENT_DYNCREATE(CMyListView, CListView)

CMyListView::CMyListView()
{
}

CMyListView::~CMyListView()
{
}


BEGIN_MESSAGE_MAP(CMyListView, CListView)
	//{{AFX_MSG_MAP(CMyListView)
	ON_WM_CREATE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMyListView drawing

void CMyListView::OnDraw(CDC* pDC)
{
	CDocument* pDoc = GetDocument();
	// TODO: add draw code here
}

/////////////////////////////////////////////////////////////////////////////
// CMyListView diagnostics

#ifdef _DEBUG
void CMyListView::AssertValid() const
{
	CListView::AssertValid();
}

void CMyListView::Dump(CDumpContext& dc) const
{
	CListView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMyListView message handlers



BOOL CMyListView::PreCreateWindow(CREATESTRUCT& cs) 
{
	// TODO: Add your specialized code here and/or call the base class
	cs.style |= LVS_REPORT;

	return CListView::PreCreateWindow(cs);
}

void CMyListView::OnInitialUpdate() 
{
	CListView::OnInitialUpdate();
	
	// TODO: Add your specialized code here and/or call the base class
	int i = 0;
	this->GetListCtrl().SetExtendedStyle(LVS_EX_FULLROWSELECT);

	for(i = 0; i<MAXTITLE; i++)
	{
		this->GetListCtrl().InsertColumn(i,Title[i],LVCFMT_CENTER);

	}
	CRect rect;
	GetClientRect(&rect);

	for(i = 0; i<MAXTITLE; i++)
	{
		this->GetListCtrl().SetColumnWidth(i,rect.Width()/(MAXTITLE+1));
	}

	
}

UINT CMyListView::AddNewItems(struct QueueNode * const list) const
{
	int n = this->GetListCtrl().GetItemCount();
	struct PCB * pcb = NULL;
	struct QueueNode * pCur = NULL;
	
	if(!list)	return this->GetListCtrl().DeleteAllItems();

	if(!this->GetListCtrl().DeleteAllItems())	return -1;
	
	pCur = list->next;

	while(pCur->ppcb)
	{
		n = this->GetListCtrl().GetItemCount();
		pcb = pCur->ppcb;

		CString str = "";
		str.Format("%d",n);
		GetListCtrl().InsertItem(n,str);

		GetListCtrl().SetItem(n,1,LVIF_TEXT,pcb->strname,0,0,0,0);

		str.Format("%d",pcb->nid);
		GetListCtrl().SetItem(n,2,LVIF_TEXT,str,0,0,0,0);

		str.Format("%d",pcb->priority);
		GetListCtrl().SetItem(n,3,LVIF_TEXT,str,0,0,0,0);

		str.Format("%d",pcb->current_time);
		GetListCtrl().SetItem(n,4,LVIF_TEXT,str,0,0,0,0);

		str.Format("%d",pcb->total_time);
		GetListCtrl().SetItem(n,5,LVIF_TEXT,str,0,0,0,0);

		switch(pcb->state)
		{
		case PS_RUNNING:
			str = "运行";
			break;
		case PS_SLEEP:
			str = "休眠";
			break;
		case PS_SUPPOND:
			str = "挂起";
			break;
		case PS_READY:
			str = "就绪未入队";
			break;
		case PS_ACTIVE:
			str = "活跃";
			break;
		default:
			str.Format("%s","无状态");
			break;
		}
		GetListCtrl().SetItem(n,6,LVIF_TEXT,str,0,0,0,0);
		GetListCtrl().EnsureVisible(n,FALSE);
		pCur = pCur->next;
	}

	return pcb->nid;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -