OSDemoView.cpp
资源名称:OSDemo [点击查看]
上传用户:tianjwyx
上传日期:2007-01-13
资源大小:813k
文件大小:6k
源码类别:
操作系统开发
开发平台:
Visual C++
- // OSDemoView.cpp : implementation of the COSDemoView class
- //
- #include "stdafx.h"
- #include "OSDemo.h"
- #include "OSDemoDoc.h"
- #include "OSDemoView.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // COSDemoView
- IMPLEMENT_DYNCREATE(COSDemoView, CFormView)
- BEGIN_MESSAGE_MAP(COSDemoView, CFormView)
- //{{AFX_MSG_MAP(COSDemoView)
- ON_COMMAND(ID_MENU_TEST1, OnMenuTest1)
- ON_UPDATE_COMMAND_UI(ID_MENU_TEST1, OnUpdateMenuTest1)
- ON_COMMAND(ID_MENU_TEST2, OnMenuTest2)
- ON_COMMAND(ID_MENU_TEST3, OnMenuTest3)
- ON_COMMAND(ID_MENU_TEST4, OnMenuTest4)
- ON_NOTIFY(TCN_SELCHANGE, IDC_TAB_DEMO, OnSelchangeTabDemo)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // COSDemoView construction/destruction
- COSDemoView::COSDemoView()
- : CFormView(COSDemoView::IDD)
- {
- //{{AFX_DATA_INIT(COSDemoView)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- // TODO: add construction code here
- }
- COSDemoView::~COSDemoView()
- {
- }
- void COSDemoView::DoDataExchange(CDataExchange* pDX)
- {
- CFormView::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(COSDemoView)
- DDX_Control(pDX, IDC_TAB_DEMO, m_Tab);
- //}}AFX_DATA_MAP
- }
- BOOL COSDemoView::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- return CFormView::PreCreateWindow(cs);
- }
- void COSDemoView::OnInitialUpdate()
- {
- CFormView::OnInitialUpdate();
- GetParentFrame()->RecalcLayout();
- ResizeParentToFit();
- }
- /////////////////////////////////////////////////////////////////////////////
- // COSDemoView printing
- BOOL COSDemoView::OnPreparePrinting(CPrintInfo* pInfo)
- {
- // default preparation
- return DoPreparePrinting(pInfo);
- }
- void COSDemoView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add extra initialization before printing
- }
- void COSDemoView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add cleanup after printing
- }
- void COSDemoView::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/)
- {
- // TODO: add customized printing code here
- }
- /////////////////////////////////////////////////////////////////////////////
- // COSDemoView diagnostics
- #ifdef _DEBUG
- void COSDemoView::AssertValid() const
- {
- CFormView::AssertValid();
- }
- void COSDemoView::Dump(CDumpContext& dc) const
- {
- CFormView::Dump(dc);
- }
- COSDemoDoc* COSDemoView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(COSDemoDoc)));
- return (COSDemoDoc*)m_pDocument;
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // COSDemoView message handlers
- void COSDemoView::OnDraw(CDC* pDC)
- {
- CRect rcClient;
- pDC->GetClipBox(rcClient); //获取需刷新的逻辑坐标区域
- rcClient.NormalizeRect();
- if (rcClient.IsRectEmpty()) //不需刷新时直接返回
- return;
- //绘制客户区的底色
- CBrush brush;
- brush.CreateSolidBrush(RGB(222,227,247));
- pDC->FillRect(rcClient, &brush);
- brush.DeleteObject();
- if (!bTabInit)
- {
- bTabInit=true;
- m_Tab.AddPage(" 作业调度 ", &m_Tab1, IDD_TAB1);
- m_Tab.AddPage(" 进程调度 ", &m_Tab2, IDD_TAB2);
- m_Tab.AddPage(" 请求页式 ", &m_Tab3, IDD_TAB3);
- m_Tab.AddPage(" 文件管理 ", &m_Tab4, IDD_TAB4);
- m_Tab.Show();
- }
- }
- void COSDemoView::ApplySkin(int n)
- {
- switch(n)
- {
- case 1:
- break;
- case 7:
- break;
- default:
- CFile f;
- char pSkinFile[64];
- GetTempPath(sizeof(pSkinFile),pSkinFile);
- char* pFileName = "myskin.smf";
- strcat(pSkinFile,pFileName);
- DeleteFile(pFileName);
- if( !f.Open( pSkinFile, CFile::modeCreate | CFile::modeWrite, NULL ) )
- {
- AfxMessageBox("Can not create file!");
- }
- CString path = f.GetFilePath();
- HGLOBAL hRes;
- HRSRC hResInfo;
- HINSTANCE insApp = AfxGetInstanceHandle();
- hResInfo = FindResource(insApp,(LPCSTR)IDR_SHELL1+n-2,"SHELL");
- hRes = LoadResource(insApp,hResInfo ); // Load it
- DWORD dFileLength = SizeofResource( insApp, hResInfo ); //计算EXE文件大小
- f.WriteHuge((LPSTR)hRes,dFileLength); //写入临时文件
- f.Close();
- m_Tab.ShowWindow(SW_HIDE);
- LoadSkinFile(pSkinFile);
- m_Tab.ShowWindow(SW_SHOW);
- }
- }
- void COSDemoView::OnMenuTest1()
- {
- m_Tab.SetCurSel(0);
- }
- void COSDemoView::OnUpdateMenuTest1(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- }
- void COSDemoView::OnMenuTest2()
- {
- m_Tab.SetCurSel(1);
- CRect rect;
- m_Tab2.m_Exer2.GetWindowRect(&rect);
- CPoint pt = rect.CenterPoint();
- ShowBallTip(pt,"抱歉,由于本实验和作业管理比较类似,所以不做了!");
- }
- void COSDemoView::OnMenuTest3()
- {
- // TODO: Add your command handler code here
- m_Tab.SetCurSel(2);
- }
- void COSDemoView::OnMenuTest4()
- {
- // TODO: Add your command handler code here
- m_Tab.SetCurSel(3);
- CRect rect;
- m_Tab4.m_LoginBtn.GetWindowRect(&rect);
- CPoint pt = rect.CenterPoint();
- ShowBallTip(pt,"单击这里登录文件系统!");
- }
- void COSDemoView::OnSelchangeTabDemo(NMHDR* pNMHDR, LRESULT* pResult)
- {
- if(m_Tab.GetCurSel()==3)
- {
- CRect rect;
- m_Tab4.m_LoginBtn.GetWindowRect(&rect);
- CPoint pt = rect.CenterPoint();
- ShowBallTip(pt,"单击这里登录文件系统!");
- }
- if(m_Tab.GetCurSel()==1)
- {
- CRect rect;
- m_Tab2.m_Exer2.GetWindowRect(&rect);
- CPoint pt = rect.CenterPoint();
- ShowBallTip(pt,"抱歉,由于本实验和作业管理比较类似,所以不做了!");
- }
- *pResult = 0;
- }
- void COSDemoView::ShowBallTip(CPoint pt, CString msg)
- {
- LOGFONT lf;
- ::ZeroMemory (&lf, sizeof (lf));
- lf.lfHeight = 15;
- lf.lfWeight = FW_BOLD;
- lf.lfUnderline = FALSE;
- ::strcpy (lf.lfFaceName, _T("楷体_GB2312"));
- m_pBalloonTip = CBalloonTip::Show(pt, CSize(250, 100), msg, lf, 5, TRUE);
- }