Myoptionbar.cpp
上传用户:netltd
上传日期:2013-02-12
资源大小:7234k
文件大小:4k
源码类别:

绘图程序

开发平台:

Visual C++

  1. #include "stdafx.h"
  2. #include "resource.h" 
  3. #include "MyOptionBar.h"
  4. BOOL COptionBar::Create(CWnd* pWnd, UINT nIDTemplate, UINT nID)
  5. {
  6.     if(!CDialogBar::Create(pWnd, nIDTemplate, CBRS_TOP | CBRS_TOOLTIPS 
  7.                | CBRS_FLYBY | CBRS_HIDE_INPLACE, nID))
  8.     {
  9.     return FALSE;
  10. }
  11. else
  12. {
  13. return TRUE;
  14. }
  15. }
  16. void COptionBar::Initialize()
  17. {
  18. SetWindowText (_T("选项条"));
  19. CComboBoxEx* pColorCombo = (CComboBoxEx*)GetDlgItem(IDC_COLOR);
  20. CComboBoxEx* pLineStyleCombo = (CComboBoxEx*)GetDlgItem(IDC_LINESTYLE);
  21. CComboBox*   pSizeCombo = (CComboBox*)GetDlgItem(IDC_PROPORTION);
  22. //初始化"前景色"复选框
  23. CImageList  m_ColorImageList;
  24. m_ColorImageList.Create(16, 16, ILC_MASK, 1, 1);
  25. m_ColorImageList.Add(AfxGetApp()->LoadIcon(IDI_BLACK));
  26. m_ColorImageList.Add(AfxGetApp()->LoadIcon(IDI_RED));
  27. m_ColorImageList.Add(AfxGetApp()->LoadIcon(IDI_YELLOW));
  28. m_ColorImageList.Add(AfxGetApp()->LoadIcon(IDI_GREEN));
  29. m_ColorImageList.Add(AfxGetApp()->LoadIcon(IDI_CYAN));
  30.     m_ColorImageList.Add(AfxGetApp()->LoadIcon(IDI_BLUE));
  31. m_ColorImageList.Add(AfxGetApp()->LoadIcon(IDI_MAGENTA));
  32. pColorCombo->SetImageList(&m_ColorImageList);
  33. m_ColorImageList.Detach();
  34. COMBOBOXEXITEM     ColorItem;
  35. ColorItem.mask = CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBEIF_TEXT;
  36. ColorItem.iItem = 0;
  37. ColorItem.iImage = 0;
  38. ColorItem.iSelectedImage = 0;
  39. ColorItem.pszText = "黑色";
  40. pColorCombo->InsertItem(&ColorItem);
  41. ColorItem.iItem = 1;
  42. ColorItem.iImage = 1;
  43. ColorItem.iSelectedImage = 1;
  44. ColorItem.pszText = "红色";
  45. pColorCombo->InsertItem(&ColorItem);
  46. ColorItem.iItem = 2;
  47. ColorItem.iImage = 2;
  48. ColorItem.iSelectedImage = 2;
  49. ColorItem.pszText = "黄色";
  50. pColorCombo->InsertItem(&ColorItem);
  51. ColorItem.iItem = 3;
  52. ColorItem.iImage = 3;
  53. ColorItem.iSelectedImage = 3;
  54. ColorItem.pszText = "绿色";
  55. pColorCombo->InsertItem(&ColorItem);
  56. ColorItem.iItem = 4;
  57. ColorItem.iImage = 4;
  58. ColorItem.iSelectedImage = 4;
  59. ColorItem.pszText = "青色";
  60. pColorCombo->InsertItem(&ColorItem);
  61. ColorItem.iItem = 5;
  62. ColorItem.iImage = 5;
  63. ColorItem.iSelectedImage = 5;
  64. ColorItem.pszText = "蓝色";
  65. pColorCombo->InsertItem(&ColorItem);
  66. ColorItem.iItem = 6;
  67. ColorItem.iImage = 6;
  68. ColorItem.iSelectedImage = 6;
  69. ColorItem.pszText = "紫色";
  70. pColorCombo->InsertItem(&ColorItem);
  71. //初始化"线形"复选框
  72. CImageList  m_LineTypeImageList;
  73. CBitmap LineTypeImage;
  74. m_LineTypeImageList.Create(80, 3, ILC_MASK, 1, 1);
  75. LineTypeImage.LoadBitmap(IDB_SOLID);
  76. m_LineTypeImageList.Add(&LineTypeImage, RGB(255, 255, 255));
  77. LineTypeImage.Detach();
  78. LineTypeImage.LoadBitmap(IDB_DASH);
  79. m_LineTypeImageList.Add(&LineTypeImage, RGB(255, 255, 255));
  80. LineTypeImage.Detach();
  81. LineTypeImage.LoadBitmap(IDB_DOT);
  82. m_LineTypeImageList.Add(&LineTypeImage, RGB(255, 255, 255));
  83. LineTypeImage.Detach();
  84. LineTypeImage.LoadBitmap(IDB_DASHDOT);
  85. m_LineTypeImageList.Add(&LineTypeImage, RGB(255, 255, 255));
  86. LineTypeImage.Detach();
  87. LineTypeImage.LoadBitmap(IDB_DASHDOTDOT);
  88. m_LineTypeImageList.Add(&LineTypeImage, RGB(255, 255, 255));
  89. pLineStyleCombo->SetImageList(&m_LineTypeImageList);
  90. m_LineTypeImageList.Detach();
  91.         
  92. COMBOBOXEXITEM     LineTypeItem;
  93. LineTypeItem.mask = CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBEIF_TEXT;
  94. LineTypeItem.iItem = 0;
  95. LineTypeItem.iImage = 0;
  96. LineTypeItem.iSelectedImage = 0;
  97. LineTypeItem.pszText = "实线";
  98. pLineStyleCombo->InsertItem(&LineTypeItem);
  99. LineTypeItem.iItem = 1;
  100. LineTypeItem.iImage = 1;
  101. LineTypeItem.iSelectedImage = 1;
  102. LineTypeItem.pszText = "虚线";
  103. pLineStyleCombo->InsertItem(&LineTypeItem);
  104. LineTypeItem.iItem = 2;
  105. LineTypeItem.iImage = 2;
  106. LineTypeItem.iSelectedImage = 2;
  107. LineTypeItem.pszText = "点线";
  108. pLineStyleCombo->InsertItem(&LineTypeItem);
  109. LineTypeItem.iItem = 3;
  110. LineTypeItem.iImage = 3;
  111. LineTypeItem.iSelectedImage = 3;
  112. LineTypeItem.pszText = "点划线";
  113. pLineStyleCombo->InsertItem(&LineTypeItem);
  114. LineTypeItem.iItem = 4;
  115. LineTypeItem.iImage = 4;
  116. LineTypeItem.iSelectedImage = 4;
  117. LineTypeItem.pszText = "双点划线";
  118. pLineStyleCombo->InsertItem(&LineTypeItem);
  119. //使其失效
  120.     pColorCombo->EnableWindow(FALSE);
  121. pLineStyleCombo->EnableWindow(FALSE);
  122. pSizeCombo->EnableWindow(FALSE);
  123. }