MILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'" twffan="done">
图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); } |