【编者按】网学网ASP.net频道为大家收集整理了“Visual C++ 2005图像编程之属性设置栏“提供大家参考,希望对大家有所帮助!
工具箱含有选择、填充、画线等功能。使用这些工具时有的需要设置填充风格和线条的大小。为了方便用户操作,实现更简易的UI,实现了属性工具栏。属性栏需要添加的主要功能有2个显示文字的静态文本框和2个组合框。 图2-1 |
class CToolBoxPropBar { ………………//省略部分代码 CStatic m_Static; CStatic m_Static2; CComboBox m_BrushStyle; CComboBox m_BrushSize; void CreateSubControl(); }; |
void CToolBoxPropBar:: CreateSubControl () { HGDIOBJ hFont = GetStockObject( DEFAULT_GUI_FONT ); //取默认GUI字体 CFont font; font.Attach( hFont ); //将IDC_1(图2-1中数字1按钮的ID)按钮设置为分隔条 int nIndex = GetToolBarCtrl().CommandToIndex(IDC_1); SetButtonInfo(nIndex, IDC_1, TBBS_SEPARATOR, 60); //60表示控件的宽度 RECT rect; GetItemRect(nIndex, &rect); m_Static.Create(_T("填充风格:"), WS_CHILD|WS_VISIBLE, rect, this, IDC_STATIC); m_Static.SetFont(&font); nIndex = GetToolBarCtrl().CommandToIndex(IDC_2); SetButtonInfo(nIndex, IDC_2, TBBS_SEPARATOR, 100); GetItemRect(nIndex, &rect); m_BrushStyle.Create("", WS_CHILD|WS_VISIBLE, rect, this, ID_COMBOBOX_STYEL); nIndex = GetToolBarCtrl().CommandToIndex(IDC_3); SetButtonInfo(nIndex, IDC_3, TBBS_SEPARATOR, 60); GetItemRect(nIndex, &rect); m_Static2.Create(_T("画刷大小:"), WS_CHILD|WS_VISIBLE|, rect, this, IDC_3); m_Static2.SetFont(&font); nIndex = GetToolBarCtrl().CommandToIndex(IDC_4); SetButtonInfo(nIndex, IDC_4, TBBS_SEPARATOR, 50); GetItemRect(nIndex, &rect); m_BrushSize.Create("", WS_CHILD|WS_VISIBLE, rect, this, ID_COMBOBOX_WIDTH); m_BrushSize.SetFont(&font); } |