{"id":6353,"date":"2012-10-11T07:00:00","date_gmt":"2012-10-11T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2012\/10\/11\/combo-boxes-have-supported-incremental-searching-for-quite-some-time-now\/"},"modified":"2012-10-11T07:00:00","modified_gmt":"2012-10-11T07:00:00","slug":"combo-boxes-have-supported-incremental-searching-for-quite-some-time-now","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20121011-00\/?p=6353","title":{"rendered":"Combo boxes have supported incremental searching for quite some time now"},"content":{"rendered":"<p>Back in August 2007,\n<a HREF=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2007\/08\/27\/4580767.aspx#4593428\">\nI promised to post a program the following day<\/a>\nbut it appears that I never did.\nOops.\nI discovered this as I went through my &#8220;things to blog about&#8221; pile\nand figured better late than never.\nThough five years late is pretty bad.\n<\/p>\n<p>\nHere&#8217;s a program which fills a combo box with some strings.\n<\/p>\n<pre>\n#include &lt;windows.h&gt;\n#include &lt;windowsx.h&gt;\nstatic LPCTSTR rgpszList[] = {\n    TEXT(\"Austria\"),\n    TEXT(\"Belgium\"),\n    TEXT(\"Bulgaria\"),\n    TEXT(\"Cyprus\"),\n    TEXT(\"Czech Republic\"),\n    TEXT(\"Denmark\"),\n    TEXT(\"Estonia\"),\n    TEXT(\"Finland\"),\n    TEXT(\"France\"),\n    TEXT(\"Germany\"),\n    TEXT(\"Greece\"),\n    TEXT(\"Hungary\"),\n    TEXT(\"Ireland\"),\n    TEXT(\"Italy\"),\n    TEXT(\"Latvia\"),\n    TEXT(\"Lithuania\"),\n    TEXT(\"Luxembourg\"),\n    TEXT(\"Malta\"),\n    TEXT(\"Netherlands\"),\n    TEXT(\"Poland\"),\n    TEXT(\"Portugal\"),\n    TEXT(\"Romania\"),\n    TEXT(\"Slovakia\"),\n    TEXT(\"Slovenia\"),\n    TEXT(\"Spain\"),\n    TEXT(\"Sweden\"),\n    TEXT(\"United Kingdom\"),\n};\nINT_PTR CALLBACK DlgProc(HWND hdlg, UINT uMsg, WPARAM wParam, LPARAM lParam)\n{\n    switch (uMsg) {\n    case WM_INITDIALOG:\n        for (int i = 0; i &lt; ARRAYSIZE(rgpszList); i++) {\n            SendDlgItemMessage(hdlg, 100, CB_ADDSTRING, 0,\n                               (LPARAM)rgpszList[i]);\n        }\n        return TRUE;\n    case WM_COMMAND:\n        if (GET_WM_COMMAND_ID(wParam, lParam) == IDCANCEL) {\n            EndDialog(hdlg, 0);\n        }\n        break;\n    }\n    return FALSE;\n}\nint WINAPI WinMain(HINSTANCE hinst, HINSTANCE hinstPrev,\n                   LPSTR lpCmdLine, int nShowCmd)\n{\n    DialogBox(hinst, MAKEINTRESOURCE(1), NULL, DlgProc);\n    return 0;\n}\n\/\/ scratch.rc\n#include &lt;windows.h&gt;\n1 DIALOG 50, 50, 185, 98\nSTYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_DLGFRAME | WS_SYSMENU\nBEGIN\n    COMBOBOX 100,7,40,150,300,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL\nEND\n<\/pre>\n<p>\nRun this program and start typing:\n&#8220;S&#8221;-&#8220;L&#8221;-&#8220;O&#8221;-&#8220;V&#8221;-&#8220;E&#8221;&#8230;\nHey, look, the combo box is performing incremental search and once\nyou hit the &#8220;E&#8221;, it selected Slovenia, the first item in the list\nwhich begins with the letters S-L-O-V-E.\n<\/p>\n<p>\nWait a few seconds, and try it again.\nThis time, type &#8220;S&#8221;-&#8220;P&#8221;, and hey look, it selected Spain.\nYou didn&#8217;t have to go through all those other &#8220;S&#8221; countries to get to it.\n<\/p>\n<p>\nIf you hit F4 to open the combo box and then type\n&#8220;S&#8221;-&#8220;L&#8221;-&#8220;O&#8221;-&#8220;V&#8221;-&#8220;E&#8221;,\nobserve that there is a tiny vertical line that tells you where\nyou are in the incremental search string.\n<\/p>\n<p>\nAs I noted some time ago,\nthe incremental search resets after\n<a HREF=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2008\/04\/23\/8417521.aspx\">\nfour times the double-click time<\/a>,\nor two seconds by default.\n<\/p>\n<p>\n<b>Note<\/b>:\nThe &#8220;things to blog about&#8221; pile has over 2000 items in it,\nso there really isn&#8217;t much need for a Suggestion Box,\nbut I open it up once every few years just for show.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Back in August 2007, I promised to post a program the following day but it appears that I never did. Oops. I discovered this as I went through my &#8220;things to blog about&#8221; pile and figured better late than never. Though five years late is pretty bad. Here&#8217;s a program which fills a combo box [&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-6353","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>Back in August 2007, I promised to post a program the following day but it appears that I never did. Oops. I discovered this as I went through my &#8220;things to blog about&#8221; pile and figured better late than never. Though five years late is pretty bad. Here&#8217;s a program which fills a combo box [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/6353","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=6353"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/6353\/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=6353"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=6353"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=6353"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}