Date: | September 20, 2010 / year-entry #264 |
Tags: | code |
Orig Link: | https://blogs.msdn.microsoft.com/oldnewthing/20100920-00/?p=12813 |
Comments: | 3 |
Summary: | Via the Suggestion Box, commenter Twisted Combo responds to an old blog entry on why the size of a combo box includes the height of the drop-down by asking, But how do I *get* the dropped down height?" By using the deviously-named CB_GETDROPPEDCONTROLRECT message, which the windowsx.h header file wraps inside the ComboBox_GetDroppedControlRect macro. Start... |
Via the Suggestion Box, commenter Twisted Combo responds to an old blog entry on why the size of a combo box includes the height of the drop-down by asking, But how do I *get* the dropped down height?"
By using the deviously-named
Start with the scratch program and make these changes: BOOL OnCreate(HWND hwnd, LPCREATESTRUCT lpcs) { g_hwndChild = CreateWindow( TEXT("combobox"), NULL, WS_CHILD | WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWN, 0, 0, 500, 500, hwnd, (HMENU)1, g_hinst, 0); ComboBox_AddString(g_hwndChild, TEXT("First")); ComboBox_AddString(g_hwndChild, TEXT("Second")); ComboBox_AddString(g_hwndChild, TEXT("Third")); ComboBox_AddString(g_hwndChild, TEXT("Fourth")); TCHAR szBuf[200]; RECT rcWindow; GetWindowRect(g_hwndChild, &rcWindow); RECT rcDrop; ComboBox_GetDroppedControlRect(g_hwndChild, &rcDrop); wsprintf(szBuf, TEXT("window height %d, dropdown height %d"), rcWindow.bottom - rcWindow.top, rcDrop.bottom - rcDrop.top); SetWindowText(hwnd, szBuf); return TRUE; } The actual results will naturally vary depending on your system configuration, but when I ran this program, the window caption said "24 / 500". |
Comments (3)
Comments are closed. |
As a reminder, when you edit your dialog layout, make sure to expand the dropbox size. The default size is like 1 line.
IIRC the dialog height issue does not apply when visual styles are enabled
What is the correct programmatic way to set the height? There is no ComboBox_SetDroppedControlRect