Sysinfo.cpp
上传用户:zhenhuadz
上传日期:2007-01-07
资源大小:1511k
文件大小:4k
源码类别:

远程控制编程

开发平台:

Visual C++

  1. // Sysinfo.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "anywhere.h"
  5. #include "Sysinfo.h"
  6. #include "anywheredoc.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CSysinfo
  14. IMPLEMENT_DYNCREATE(CSysinfo, CScrollView)
  15. CSysinfo::CSysinfo()
  16. {
  17. }
  18. CSysinfo::~CSysinfo()
  19. {
  20. }
  21. BEGIN_MESSAGE_MAP(CSysinfo, CScrollView)
  22. //{{AFX_MSG_MAP(CSysinfo)
  23. ON_WM_CREATE()
  24. ON_WM_SIZE()
  25. //}}AFX_MSG_MAP
  26. END_MESSAGE_MAP()
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CSysinfo drawing
  29. static int _gCaption[] =
  30. {
  31. IDS_COMPUTERNAME,
  32. IDS_USERNAME,
  33. //IDS_CPUTYPE,
  34.     IDS_PRODUCTOR,
  35. IDS_CPUIDENTY,
  36. IDS_CPULEVEL,
  37. IDS_CPUNUM,
  38. IDS_PHYMEM,
  39. IDS_PHYMEMAVB
  40. };
  41. void CSysinfo::OnInitialUpdate()
  42. {
  43. CScrollView::OnInitialUpdate();
  44.     //CAnywhereDoc *pMydoc=GetDocument();
  45. CSize sizeTotal(200,200);
  46. // TODO: calculate the total size of this view
  47. CSize sizePage(sizeTotal.cx/2,sizeTotal.cy/2);
  48. CSize sizeLine(sizeTotal.cx/5,sizeTotal.cy/5);
  49. //sizeTotal.cx = sizeTotal.cy = 100;
  50. //SetScrollSizes(MM_TEXT, sizeTotal);
  51. SetScrollSizes(MM_TEXT,sizeTotal,sizePage,sizeLine);
  52. }
  53. void CSysinfo::OnDraw(CDC* pDC)
  54. {
  55. // TODO: add draw code here
  56. }
  57. /////////////////////////////////////////////////////////////////////////////
  58. // CSysinfo diagnostics
  59. #ifdef _DEBUG
  60. void CSysinfo::AssertValid() const
  61. {
  62. CScrollView::AssertValid();
  63. }
  64. void CSysinfo::Dump(CDumpContext& dc) const
  65. {
  66. CScrollView::Dump(dc);
  67. }
  68. #endif //_DEBUG
  69. /////////////////////////////////////////////////////////////////////////////
  70. // CSysinfo message handlers
  71. void CSysinfo::ShowFont(CDC *pDC, int &nPos, CString text,CString data)
  72. {
  73. TEXTMETRIC tm;
  74. CSize sizetext;
  75. //int pos=10;
  76.     pDC->GetTextMetrics(&tm);
  77. CAnywhereDoc *pDoc =(CAnywhereDoc *)GetDocument();
  78. pDC->SelectObject(&pDoc->m_Fontst);
  79. sizetext=pDC->GetTextExtent(text);
  80. pDC->TextOut(10,nPos,text);
  81.     //pDC->SetTextColor(RGB(0,0,255));
  82. pDC->TextOut(200,nPos,data);
  83.     //pDC->SetTextColor(RGB(255,255,255));
  84. nPos+=sizetext.cy+10;
  85.     //nPos-=tm.tmHeight+tm.tmExternalLeading;
  86. //pDC->SetTextColor(RGB(0,0,255));
  87. //pos+=sizetext.cy;
  88. }
  89. int CSysinfo::OnCreate(LPCREATESTRUCT lpCreateStruct) 
  90. {
  91. if (CScrollView::OnCreate(lpCreateStruct) == -1)
  92. return -1;
  93.     CRect rect;
  94. GetClientRect(&rect);
  95. m_listctrl.Create(WS_CHILD|WS_BORDER|WS_VISIBLE|LVS_REPORT|LVS_NOSORTHEADER,rect,this,IDC_SYSINFO);
  96.     m_listctrl.InsertColumn(0, "说明", LVCFMT_LEFT,rect.Width()/3);
  97. m_listctrl.InsertColumn(1, "属性", LVCFMT_LEFT, rect.Width()/2);
  98. m_listctrl.ShowWindow(SW_SHOW);
  99. m_ImageList.Create(16,16,ILC_COLOR16|ILC_MASK,8,1);//16x16是小尺寸
  100. m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_COMPUTER));
  101. m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_USER));
  102. m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_PRODUCTOR));
  103. m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_CPUIDEN));
  104. m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_PLUS));
  105. m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_NUM));
  106. m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_PHYMEM));
  107. m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_AVBMEM));
  108. m_listctrl.SetImageList(&m_ImageList,LVSIL_SMALL);
  109.     
  110. //message("");
  111. return 0;
  112. }
  113. void CSysinfo::message(CString text)
  114. {
  115. CAnywhereDoc *pDoc =(CAnywhereDoc *)GetDocument();
  116. //int yy=text.IsEmpty();
  117. //return ;
  118. BOOL bFinished=FALSE;
  119. int num=0;
  120. int pos;
  121.     while (!bFinished) {
  122. if ((pos=text.Find("*"))!=-1)
  123. {
  124. pDoc->m_sys[num]=text.Left(pos);
  125. text=text.Right(text.GetLength()-pos-1);
  126. num++;
  127. }
  128.         else bFinished=TRUE;
  129. }
  130. CString tmp;
  131. m_listctrl.DeleteAllItems( );
  132. for (int i=0;i<8;i++)
  133. {
  134.     tmp.LoadString(_gCaption[i]);
  135. //text.Format("%-10s",tmp);
  136. //text+=pDoc->m_sys[i];
  137. //ShowFont(pDC,nPosition,text,pDoc->m_sys[i]);
  138. m_listctrl.InsertItem(i,tmp,i);
  139. m_listctrl.SetItemText(i,1,pDoc->m_sys[i]);
  140. }
  141. CString sSucmsg,caption;
  142. sSucmsg.LoadString(IDS_ACTION_OK);
  143. caption.LoadString(IDS_CAPTION);
  144. MessageBox(sSucmsg,caption,MB_OK);
  145. }
  146. void CSysinfo::OnSize(UINT nType, int cx, int cy) 
  147. {
  148. CScrollView::OnSize(nType, cx, cy);
  149.     if (m_listctrl.GetSafeHwnd())
  150.    {
  151. //CRect rect;
  152. //GetClientRect(&rect);
  153. //rect.top=rect.bottom/4;
  154. //rect.bottom=rect.top+rect.top;
  155. //rect.left=rect.right/4;
  156. //rect.right=rect.left+rect.left;
  157. m_listctrl.MoveWindow(0,0,cx,cy,TRUE);
  158. }
  159. }