본문 바로가기
C | C++ | VC++

툴바에 텍스트 추가시 세로폭(높이) 가 커지는데 줄이는 방법

by 두루물 2010. 9. 16.

툴바에 텍스트 추가시 세로폭(높이) 가 커지는데 줄이는 방법
How to decrease ToolBar Height when added text and dropdown style

 SetToolbarText(IDM_FIND);
 SetToolbarText(IDM_REPLACE);

 dwButtonStyle = m_ToolBar.GetButtonStyle(m_ToolBar.CommandToIndex(IDM_FIND));
 dwButtonStyle |= (BTNS_DROPDOWN | BTNS_CHECK |BTNS_AUTOSIZE);//여기서 BTNS_AUTOSIZE로해야 버튼들의 폭이 일률적으로 같게 안들어난다.
 m_ToolBar.SetButtonStyle(m_ToolBar.CommandToIndex(IDM_FIND), dwButtonStyle);

 dwButtonStyle = m_ToolBar.GetButtonStyle(m_ToolBar.CommandToIndex(IDM_REPLACE));
 dwButtonStyle |= (BTNS_DROPDOWN | BTNS_CHECK |BTNS_AUTOSIZE);
 m_ToolBar.SetButtonStyle(m_ToolBar.CommandToIndex(IDM_REPLACE), dwButtonStyle);

위 처럼, 툴바에 텍스트 + 드롭다운 시 세로폭이 엄청 커지게 된다.
이를 줄이는 방법은,
 /*텍스트가 포함될 때 cy가 늘어나는데 사이즈를 줄이게 조절*/
 TBMETRICS tb;
 tb.cbSize = sizeof(TBMETRICS);
 tb.dwMask = 0xff;
 m_ToolBar.GetMetrics(&tb);
 tb.cyPad = 1;
 m_ToolBar.SetMetrics(&tb);

하여 padding 값을 줄이면 아이콘만 있을때 처럼 줄일수 있다.

출처:본인