PapersBar.cpp
上传用户:wujian85
上传日期:2010-04-08
资源大小:227k
文件大小:4k
源码类别:

对话框与窗口

开发平台:

Visual C++

  1. // PapersBar.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "printformeditor.h"
  5. #include "PapersBar.h"
  6. #include "Doc.h"
  7. #include "MainFrm.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CPapersBar
  15. CPapersBar::CPapersBar()
  16. {
  17. lima.Create(32,32,ILC_MASK|ILC_COLOR8, 0, 2);
  18. lima.Add((HICON) AfxGetApp()->LoadIcon(IDR_PRINTFTYPE));
  19. lima.Add((HICON) AfxGetApp()->LoadIcon(IDR_MAINFRAME));
  20. pDoc = NULL;
  21. }
  22. CPapersBar::~CPapersBar()
  23. {
  24. }
  25. BEGIN_MESSAGE_MAP(CPapersBar, SECControlBar)
  26. //{{AFX_MSG_MAP(CPapersBar)
  27. ON_WM_CREATE()
  28. ON_WM_SIZE()
  29. ON_WM_ERASEBKGND()
  30. ON_NOTIFY(LVN_ITEMCHANGED, 1020, OnItemchangedList1)
  31. ON_NOTIFY(LVN_ENDLABELEDIT, 1020, OnEndlabeleditList1)
  32. ON_NOTIFY(NM_SETFOCUS, 1020, OnSetfocusList1)
  33. ON_NOTIFY(NM_KILLFOCUS, 1020, OnKillfocusList1)
  34. //}}AFX_MSG_MAP
  35. END_MESSAGE_MAP()
  36. /////////////////////////////////////////////////////////////////////////////
  37. // CPapersBar message handlers
  38. void CPapersBar::OnItemchangedList1(NMHDR* pNMHDR, LRESULT* pResult) 
  39. {
  40. NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
  41. if (pNMListView->uNewState & LVIS_SELECTED || pNMListView->uNewState & LVIS_FOCUSED)
  42. {
  43. int idx = wndList.GetNextItem(-1, LVNI_SELECTED);
  44. if (idx >= 0)
  45. {
  46. if (pDoc)
  47. {
  48. pDoc->SelectPage(idx);
  49. if (GfxIsProp2())
  50. {
  51. CGfxProperty * pg = GfxGetProp2();
  52. if (!(pg->pDocument == pDoc && pg->pWnd == this))
  53. {
  54. pg->ClearTabArray();
  55. pPage1.pDoc = pDoc;
  56. pg->pDocument = pDoc;
  57. pg->pWnd = this;
  58. pPage1.Create(CPagePage1::IDD, pg);
  59. pg->AddPage(&pPage1, "Page");
  60. pg->SetCurSel(0);
  61. }
  62. else pPage1.UpdateData(false);
  63. }
  64. }
  65. }
  66. }
  67. *pResult = 0;
  68. }
  69. int CPapersBar::OnCreate(LPCREATESTRUCT lpCreateStruct) 
  70. {
  71. if (SECControlBar::OnCreate(lpCreateStruct) == -1)
  72. return -1;
  73. CRect rc;
  74. GetInsideRect(rc);
  75. wndList.Create(WS_CHILD|WS_VISIBLE|LVS_ICON|LVS_SINGLESEL|LVS_SHOWSELALWAYS|LVS_EDITLABELS,rc,this,1020);
  76. wndList.SetImageList(&lima, LVSIL_NORMAL);
  77. wndList.ModifyStyleEx(0, WS_EX_CLIENTEDGE, SWP_FRAMECHANGED);
  78. return 0;
  79. }
  80. void CPapersBar::OnSize(UINT nType, int cx, int cy) 
  81. {
  82. CRect rectInside;
  83. GetInsideRect(rectInside);
  84. if (wndList.GetSafeHwnd())
  85. wndList.SetWindowPos(0, rectInside.left, rectInside.top, rectInside.Width(), rectInside.Height(), SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOREDRAW);
  86. SECControlBar::OnSize(nType, cx, cy);
  87. // TODO: Add your message handler code here
  88. }
  89. BOOL CPapersBar::OnEraseBkgnd(CDC* pDC) 
  90. {
  91. ASSERT_VALID(pDC);
  92. // Fill background with APPWORKSPACE
  93. CBrush backBrush(GetSysColor(COLOR_BTNFACE));
  94. CBrush* pOldBrush = pDC->SelectObject(&backBrush);
  95. CRect rect;
  96. pDC->GetClipBox(&rect);     // Erase the area needed
  97. CRect rectInside;
  98. GetInsideRect(rectInside);
  99. pDC->PatBlt(rect.left, rect.top, rect.Width(), rectInside.top - rect.top, PATCOPY);
  100. pDC->PatBlt(rect.left, rectInside.bottom, rect.Width(), rect.bottom - rectInside.bottom, PATCOPY);
  101. pDC->PatBlt(rect.left, rect.top, rectInside.left - rect.left, rect.Height(), PATCOPY);
  102. pDC->PatBlt(rectInside.right, rect.top, rect.right - rectInside.right, rect.Height(), PATCOPY);
  103. pDC->SelectObject(pOldBrush);
  104. return TRUE;
  105. // return SECControlBar::OnEraseBkgnd(pDC);
  106. }
  107. void CPapersBar::OnEndlabeleditList1(NMHDR* pNMHDR, LRESULT* pResult) 
  108. {
  109. LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
  110. *pResult = 0;
  111. if (pDoc)
  112. {
  113. pDoc->RenamePage(pDispInfo->item.iItem, CString(pDispInfo->item.pszText));
  114. *pResult = 1;
  115. }
  116. }
  117. void CPapersBar::OnSetfocusList1(NMHDR* pNMHDR, LRESULT* pResult) 
  118. {
  119. if (pDoc && GfxIsProp2())
  120. {
  121. CGfxProperty * pg = GfxGetProp2();
  122. if (pg->pDocument != pDoc || pg->pWnd != this)
  123. {
  124. pg->ClearTabArray();
  125. pPage1.pDoc = pDoc;
  126. pg->pDocument = pDoc;
  127. pg->pWnd = this;
  128. pPage1.Create(CPagePage1::IDD, pg);
  129. pg->AddPage(&pPage1, "Page");
  130. pg->SetCurSel(0);
  131. }
  132. }
  133. *pResult = 0;
  134. }
  135. void CPapersBar::OnKillfocusList1(NMHDR* pNMHDR, LRESULT* pResult) 
  136. {
  137. /* if (pDoc && GfxIsProp2())
  138. {
  139. CGfxProperty * pg = GfxGetProp2();
  140. if (pg->pDocument == pDoc && pg->pWnd == this)
  141. {
  142. pg->ClearTabArray();
  143. }
  144. }
  145. */
  146. *pResult = 0;
  147. }