{"id":12813,"date":"2010-09-20T07:00:00","date_gmt":"2010-09-20T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2010\/09\/20\/how-do-i-get-the-dropped-height-of-a-combo-box\/"},"modified":"2010-09-20T07:00:00","modified_gmt":"2010-09-20T07:00:00","slug":"how-do-i-get-the-dropped-height-of-a-combo-box","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20100920-00\/?p=12813\/","title":{"rendered":"How do I get the dropped height of a combo box?"},"content":{"rendered":"<p>\nVia the Suggestion Box,\ncommenter Twisted Combo responds to\n<a HREF=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2006\/03\/10\/548537.aspx\">\nan old blog entry on why the size of a combo box includes the height\nof the drop-down<\/a> by asking,\n<a HREF=\"http:\/\/blogs.msdn.com\/oldnewthing\/pages\/407234.aspx#1761689\">But how do I *get* the dropped down height<\/a>?&#8221;\n<\/p>\n<p>\nBy using the deviously-named\n<code>CB_GETDROPPEDCONTROLRECT<\/code> message,\nwhich the <code>windowsx.h<\/code> header file wraps inside\nthe\n<code>ComboBox_GetDroppedControlRect<\/code> macro.\n<\/p>\n<p>\nStart with\n<a HREF=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2003\/07\/23\/54576.aspx\">\nthe scratch program<\/a>\nand make these changes:\n<\/p>\n<pre>\nBOOL\nOnCreate(HWND hwnd, LPCREATESTRUCT lpcs)\n{\n  <font COLOR=\"blue\">g_hwndChild = CreateWindow(\n      TEXT(\"combobox\"), NULL, WS_CHILD | WS_VISIBLE |\n      WS_TABSTOP | CBS_DROPDOWN,\n      0, 0, 500, 500, hwnd, (HMENU)1, g_hinst, 0);\n  ComboBox_AddString(g_hwndChild, TEXT(\"First\"));\n  ComboBox_AddString(g_hwndChild, TEXT(\"Second\"));\n  ComboBox_AddString(g_hwndChild, TEXT(\"Third\"));\n  ComboBox_AddString(g_hwndChild, TEXT(\"Fourth\"));\n  TCHAR szBuf[200];\n  RECT rcWindow;\n  GetWindowRect(g_hwndChild, &amp;rcWindow);\n  RECT rcDrop;\n  ComboBox_GetDroppedControlRect(g_hwndChild, &amp;rcDrop);\n  wsprintf(szBuf, TEXT(\"window height %d, dropdown height %d\"),\n    rcWindow.bottom - rcWindow.top, rcDrop.bottom - rcDrop.top);\n  SetWindowText(hwnd, szBuf);<\/font>\n  return TRUE;\n}\n<\/pre>\n<p>\nThe actual results will naturally vary depending on your system\nconfiguration, but when I ran this program, the window caption\nsaid &#8220;24 \/ 500&#8221;.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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?&#8221; By using the deviously-named CB_GETDROPPEDCONTROLRECT message, which the windowsx.h header file wraps inside the ComboBox_GetDroppedControlRect macro. Start [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-12813","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>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?&#8221; By using the deviously-named CB_GETDROPPEDCONTROLRECT message, which the windowsx.h header file wraps inside the ComboBox_GetDroppedControlRect macro. Start [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/12813","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=12813"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/12813\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=12813"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=12813"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=12813"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}