[VC++, MFC] How to set ComboBox DropDown Height
This is a good example of how messy working with MFC can be. Something apparently so easy could take a lot of time to figure out, so here you can find two easy ways out:
1) Designer - through the designer by default you can just resize the ComboBox width. If you want to resize the Drop Down List height you need to click on the dropdown arrow on the right, then you'll be able to resize the dropped control height. This seems so easy but if no-one tells you it's anything but intuitive. If you just need to statically fix height this'll save you a lot of bitchin'.
2) Programmatically - use the following function to programmatically resize you dropped control height. The function takes as input the number of items you want to display, but if you wanna modify it to take pixels or whatever as parameter it shouldn't be too hard (unless you're brain damaged as Scuffia is).
void SetDropDownHeight(CComboBox* pMyComboBox, int itemsToShow)
{
//Get rectangles
CRect rctComboBox, rctDropDown;
//Combo rect
pMyComboBox->GetClientRect(&rctComboBox);
//DropDownList rect
pMyComboBox->GetDroppedControlRect(&rctDropDown);
//Get Item height
int itemHeight = pMyComboBox->GetItemHeight(-1);
//Converts coordinates
pMyComboBox->GetParent()->ScreenToClient(&rctDropDown);
//Set height
rctDropDown.bottom = rctDropDown.top + rctComboBox.Height() + itemHeight*itemsToShow;
//apply changes
pMyComboBox->MoveWindow(&rctDropDown);
}
출처 : http://stackoverflow.com/questions/10920790/manually-set-mfc-ccombobox-dropdown-height-with-horizontal-scrollbar
'MS > MFC' 카테고리의 다른 글
기존의 32bit코드를 64bit로 변경 할 때 (0) | 2014.04.14 |
---|---|
SHANDLE_PTR 에러 문제 (0) | 2013.10.21 |
r6034 attempt to load the C runtime library incorrectly (0) | 2013.09.30 |
GDI+ 설정방법, 이미지출력, 투명화, 더블버퍼링, 이미지회전, jpg생성, 글자 출력, GDI와 데이터형 변환 (1) | 2013.09.11 |
GDI+ Double buffering (0) | 2013.09.11 |
mfcs80d.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined (0) | 2013.08.09 |
CListCtrl 에서 깜빡임 없애기 & 실시간 갱신 (0) | 2013.04.11 |
비주얼 스튜디오, 디버깅 브레이크 포인트 중단점이 적중되지 않습니다... (0) | 2012.09.26 |
ActiveX 관리자 권한으로 상승하여 사용 하기 (0) | 2012.09.14 |
리스트 컨트롤(CListCtrl) 안에 공용 컨트롤(CButton, CComboBox Control 등) 넣기 (0) | 2011.11.21 |