Sysinfo.cpp
资源名称:(vc).rar [点击查看]
上传用户:wpp2016
上传日期:2010-02-01
资源大小:1250k
文件大小:4k
源码类别:
Telnet服务器
开发平台:
Visual C++
- // Sysinfo.cpp : implementation file
- //
- #include "stdafx.h"
- #include "anywhere.h"
- #include "Sysinfo.h"
- #include "anywheredoc.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CSysinfo
- IMPLEMENT_DYNCREATE(CSysinfo, CScrollView)
- CSysinfo::CSysinfo()
- {
- }
- CSysinfo::~CSysinfo()
- {
- }
- BEGIN_MESSAGE_MAP(CSysinfo, CScrollView)
- //{{AFX_MSG_MAP(CSysinfo)
- ON_WM_CREATE()
- ON_WM_SIZE()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CSysinfo drawing
- static int _gCaption[] =
- {
- IDS_COMPUTERNAME,
- IDS_USERNAME,
- //IDS_CPUTYPE,
- IDS_PRODUCTOR,
- IDS_CPUIDENTY,
- IDS_CPULEVEL,
- IDS_CPUNUM,
- IDS_PHYMEM,
- IDS_PHYMEMAVB
- };
- void CSysinfo::OnInitialUpdate()
- {
- CScrollView::OnInitialUpdate();
- //CAnywhereDoc *pMydoc=GetDocument();
- CSize sizeTotal(200,200);
- // TODO: calculate the total size of this view
- CSize sizePage(sizeTotal.cx/2,sizeTotal.cy/2);
- CSize sizeLine(sizeTotal.cx/5,sizeTotal.cy/5);
- //sizeTotal.cx = sizeTotal.cy = 100;
- //SetScrollSizes(MM_TEXT, sizeTotal);
- SetScrollSizes(MM_TEXT,sizeTotal,sizePage,sizeLine);
- }
- void CSysinfo::OnDraw(CDC* pDC)
- {
- // TODO: add draw code here
- }
- /////////////////////////////////////////////////////////////////////////////
- // CSysinfo diagnostics
- #ifdef _DEBUG
- void CSysinfo::AssertValid() const
- {
- CScrollView::AssertValid();
- }
- void CSysinfo::Dump(CDumpContext& dc) const
- {
- CScrollView::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CSysinfo message handlers
- void CSysinfo::ShowFont(CDC *pDC, int &nPos, CString text,CString data)
- {
- TEXTMETRIC tm;
- CSize sizetext;
- //int pos=10;
- pDC->GetTextMetrics(&tm);
- CAnywhereDoc *pDoc =(CAnywhereDoc *)GetDocument();
- pDC->SelectObject(&pDoc->m_Fontst);
- sizetext=pDC->GetTextExtent(text);
- pDC->TextOut(10,nPos,text);
- //pDC->SetTextColor(RGB(0,0,255));
- pDC->TextOut(200,nPos,data);
- //pDC->SetTextColor(RGB(255,255,255));
- nPos+=sizetext.cy+10;
- //nPos-=tm.tmHeight+tm.tmExternalLeading;
- //pDC->SetTextColor(RGB(0,0,255));
- //pos+=sizetext.cy;
- }
- int CSysinfo::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CScrollView::OnCreate(lpCreateStruct) == -1)
- return -1;
- CRect rect;
- GetClientRect(&rect);
- m_listctrl.Create(WS_CHILD|WS_BORDER|WS_VISIBLE|LVS_REPORT|LVS_NOSORTHEADER,rect,this,IDC_SYSINFO);
- m_listctrl.InsertColumn(0, "说明", LVCFMT_LEFT,rect.Width()/3);
- m_listctrl.InsertColumn(1, "属性", LVCFMT_LEFT, rect.Width()/2);
- m_listctrl.ShowWindow(SW_SHOW);
- m_ImageList.Create(16,16,ILC_COLOR16|ILC_MASK,8,1);//16x16是小尺寸
- m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_COMPUTER));
- m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_USER));
- m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_PRODUCTOR));
- m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_CPUIDEN));
- m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_PLUS));
- m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_NUM));
- m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_PHYMEM));
- m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_AVBMEM));
- m_listctrl.SetImageList(&m_ImageList,LVSIL_SMALL);
- //message("");
- return 0;
- }
- void CSysinfo::message(CString text)
- {
- CAnywhereDoc *pDoc =(CAnywhereDoc *)GetDocument();
- //int yy=text.IsEmpty();
- //return ;
- BOOL bFinished=FALSE;
- int num=0;
- int pos;
- while (!bFinished) {
- if ((pos=text.Find("*"))!=-1)
- {
- pDoc->m_sys[num]=text.Left(pos);
- text=text.Right(text.GetLength()-pos-1);
- num++;
- }
- else bFinished=TRUE;
- }
- CString tmp;
- m_listctrl.DeleteAllItems( );
- for (int i=0;i<8;i++)
- {
- tmp.LoadString(_gCaption[i]);
- //text.Format("%-10s",tmp);
- //text+=pDoc->m_sys[i];
- //ShowFont(pDC,nPosition,text,pDoc->m_sys[i]);
- m_listctrl.InsertItem(i,tmp,i);
- m_listctrl.SetItemText(i,1,pDoc->m_sys[i]);
- }
- CString sSucmsg,caption;
- sSucmsg.LoadString(IDS_ACTION_OK);
- caption.LoadString(IDS_CAPTION);
- MessageBox(sSucmsg,caption,MB_OK);
- }
- void CSysinfo::OnSize(UINT nType, int cx, int cy)
- {
- CScrollView::OnSize(nType, cx, cy);
- if (m_listctrl.GetSafeHwnd())
- {
- //CRect rect;
- //GetClientRect(&rect);
- //rect.top=rect.bottom/4;
- //rect.bottom=rect.top+rect.top;
- //rect.left=rect.right/4;
- //rect.right=rect.left+rect.left;
- m_listctrl.MoveWindow(0,0,cx,cy,TRUE);
- }
- }