Myoptionbar.cpp
上传用户:netltd
上传日期:2013-02-12
资源大小:7234k
文件大小:4k
- #include "stdafx.h"
- #include "resource.h"
- #include "MyOptionBar.h"
- BOOL COptionBar::Create(CWnd* pWnd, UINT nIDTemplate, UINT nID)
- {
- if(!CDialogBar::Create(pWnd, nIDTemplate, CBRS_TOP | CBRS_TOOLTIPS
- | CBRS_FLYBY | CBRS_HIDE_INPLACE, nID))
- {
- return FALSE;
- }
- else
- {
-
- return TRUE;
- }
- }
- void COptionBar::Initialize()
- {
- SetWindowText (_T("选项条"));
- CComboBoxEx* pColorCombo = (CComboBoxEx*)GetDlgItem(IDC_COLOR);
- CComboBoxEx* pLineStyleCombo = (CComboBoxEx*)GetDlgItem(IDC_LINESTYLE);
- CComboBox* pSizeCombo = (CComboBox*)GetDlgItem(IDC_FILESIZE);
- //初始化"前景色"复选框
- CImageList m_ColorImageList;
- m_ColorImageList.Create(16, 16, ILC_MASK, 1, 1);
- m_ColorImageList.Add(AfxGetApp()->LoadIcon(IDI_BLACK));
- m_ColorImageList.Add(AfxGetApp()->LoadIcon(IDI_RED));
- m_ColorImageList.Add(AfxGetApp()->LoadIcon(IDI_YELLOW));
- m_ColorImageList.Add(AfxGetApp()->LoadIcon(IDI_GREEN));
- m_ColorImageList.Add(AfxGetApp()->LoadIcon(IDI_CYAN));
- m_ColorImageList.Add(AfxGetApp()->LoadIcon(IDI_BLUE));
- m_ColorImageList.Add(AfxGetApp()->LoadIcon(IDI_MAGENTA));
- pColorCombo->SetImageList(&m_ColorImageList);
- m_ColorImageList.Detach();
- COMBOBOXEXITEM ColorItem;
- ColorItem.mask = CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBEIF_TEXT;
- ColorItem.iItem = 0;
- ColorItem.iImage = 0;
- ColorItem.iSelectedImage = 0;
- ColorItem.pszText = "黑色";
- pColorCombo->InsertItem(&ColorItem);
- ColorItem.iItem = 1;
- ColorItem.iImage = 1;
- ColorItem.iSelectedImage = 1;
- ColorItem.pszText = "红色";
- pColorCombo->InsertItem(&ColorItem);
- ColorItem.iItem = 2;
- ColorItem.iImage = 2;
- ColorItem.iSelectedImage = 2;
- ColorItem.pszText = "黄色";
- pColorCombo->InsertItem(&ColorItem);
- ColorItem.iItem = 3;
- ColorItem.iImage = 3;
- ColorItem.iSelectedImage = 3;
- ColorItem.pszText = "绿色";
- pColorCombo->InsertItem(&ColorItem);
- ColorItem.iItem = 4;
- ColorItem.iImage = 4;
- ColorItem.iSelectedImage = 4;
- ColorItem.pszText = "青色";
- pColorCombo->InsertItem(&ColorItem);
- ColorItem.iItem = 5;
- ColorItem.iImage = 5;
- ColorItem.iSelectedImage = 5;
- ColorItem.pszText = "蓝色";
- pColorCombo->InsertItem(&ColorItem);
- ColorItem.iItem = 6;
- ColorItem.iImage = 6;
- ColorItem.iSelectedImage = 6;
- ColorItem.pszText = "紫色";
- pColorCombo->InsertItem(&ColorItem);
- //初始化"线形"复选框
- CImageList m_LineTypeImageList;
- CBitmap LineTypeImage;
- m_LineTypeImageList.Create(80, 3, ILC_MASK, 1, 1);
- LineTypeImage.LoadBitmap(IDB_SOLID);
- m_LineTypeImageList.Add(&LineTypeImage, RGB(255, 255, 255));
- LineTypeImage.Detach();
- LineTypeImage.LoadBitmap(IDB_DASH);
- m_LineTypeImageList.Add(&LineTypeImage, RGB(255, 255, 255));
- LineTypeImage.Detach();
- LineTypeImage.LoadBitmap(IDB_DOT);
- m_LineTypeImageList.Add(&LineTypeImage, RGB(255, 255, 255));
- LineTypeImage.Detach();
- LineTypeImage.LoadBitmap(IDB_DASHDOT);
- m_LineTypeImageList.Add(&LineTypeImage, RGB(255, 255, 255));
- LineTypeImage.Detach();
- LineTypeImage.LoadBitmap(IDB_DASHDOTDOT);
- m_LineTypeImageList.Add(&LineTypeImage, RGB(255, 255, 255));
-
- pLineStyleCombo->SetImageList(&m_LineTypeImageList);
- m_LineTypeImageList.Detach();
-
- COMBOBOXEXITEM LineTypeItem;
- LineTypeItem.mask = CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBEIF_TEXT;
- LineTypeItem.iItem = 0;
- LineTypeItem.iImage = 0;
- LineTypeItem.iSelectedImage = 0;
- LineTypeItem.pszText = "实线";
- pLineStyleCombo->InsertItem(&LineTypeItem);
- LineTypeItem.iItem = 1;
- LineTypeItem.iImage = 1;
- LineTypeItem.iSelectedImage = 1;
- LineTypeItem.pszText = "虚线";
- pLineStyleCombo->InsertItem(&LineTypeItem);
- LineTypeItem.iItem = 2;
- LineTypeItem.iImage = 2;
- LineTypeItem.iSelectedImage = 2;
- LineTypeItem.pszText = "点线";
- pLineStyleCombo->InsertItem(&LineTypeItem);
- LineTypeItem.iItem = 3;
- LineTypeItem.iImage = 3;
- LineTypeItem.iSelectedImage = 3;
- LineTypeItem.pszText = "点划线";
- pLineStyleCombo->InsertItem(&LineTypeItem);
- LineTypeItem.iItem = 4;
- LineTypeItem.iImage = 4;
- LineTypeItem.iSelectedImage = 4;
- LineTypeItem.pszText = "双点划线";
- pLineStyleCombo->InsertItem(&LineTypeItem);
- //使其失效
- pColorCombo->EnableWindow(FALSE);
- pLineStyleCombo->EnableWindow(FALSE);
- pSizeCombo->EnableWindow(FALSE);
- }