{"id":193,"date":"2014-08-20T07:00:00","date_gmt":"2014-08-20T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2014\/08\/20\/if-youre-looking-for-the-code-that-displays-a-particular-dialog-box-the-most-directly-way-to-find-it-is-to-look-for-the-dialog-box\/"},"modified":"2014-08-20T07:00:00","modified_gmt":"2014-08-20T07:00:00","slug":"if-youre-looking-for-the-code-that-displays-a-particular-dialog-box-the-most-directly-way-to-find-it-is-to-look-for-the-dialog-box","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20140820-00\/?p=193","title":{"rendered":"If you&#039;re looking for the code that displays a particular dialog box, the most directly way to find it is to look for the dialog box"},"content":{"rendered":"<p>Suppose you are working in a large or unfamiliar code base and you want to know where the code is that displays a particular dialog box or message box or something. Probably the most direct way of figuring this out is to look for the strings.\n Say there is a message box that asks for user confirmation. &#8220;Are you sure you want to frobulate the flux capacitor?&#8221; Search for that string in your source code. It will probably be in a resource file.<\/p>\n<blockquote class=\"m\"><p> <code> resource.rc:IDS_CONFIRM&shy;FROBULATE \"<u>Are you sure you want to frobulate the flux capacitor<\/u>?\" <\/code> <\/p><\/blockquote>\n<p> Great, now you have the string ID for that message. You can perform a second search for that ID.<\/p>\n<blockquote class=\"m\"><p> <code> resource.h:#define <u>IDS_CONFIRM&shy;FROBULATE<\/u> 1024<br \/> resource.rc:<u>IDS_CONFIRM&shy;FROBULATE<\/u> \"Are you sure you want to frobulate the flux capacitor?\"<br \/> maintenance.cpp: &nbsp; strPrompt.LoadString(<u>IDS_CONFIRM&shy;FROBULATE<\/u>); <\/code> <\/p><\/blockquote>\n<p> If the thing you are searching for is a dialog box or menu item, then be aware that there may be an accelerator in the string, so a straight grep won&#8217;t find it.<\/p>\n<blockquote class=\"m\"><p> <code> No matches for \"Enter the new name of the frobulator:\" <\/code> <\/p><\/blockquote>\n<p> For a dialog box, you can tap the <kbd>Alt<\/kbd> key to make the accelerator show up, so you can search for the right string. For a menu, you invoke the menu via the keyboard. Or in either case, you can disable the <i>Hide underlined letters for keyboard navigation<\/i> setting.<\/p>\n<blockquote class=\"m\"><p> <code> resource.rc:&nbsp; LTEXT \"<u>Enter the ne&amp;w name of the frobulator<\/u>:\", <\/code> <\/p><\/blockquote>\n<p> I tend to be lazy and instead of using any of those tricks to make the underlines show up, I just search for a shorter string and hope that the accelerator isn&#8217;t in it.<\/p>\n<blockquote class=\"m\"><p> <code> resource.rc:&nbsp; LTEXT \"Enter the ne&amp;w <u>name of the frobulator<\/u>:\", <\/code> <\/p><\/blockquote>\n<p> &#8220;But Raymond, hitting the <kbd>Alt<\/kbd> is just a quick tap on the keyboard. Surely you can&#8217;t be <i>that<\/i> lazy!&#8221;\n Right. If the dialog box were right in front of me, then I could tap the <kbd>Alt<\/kbd> and be done. But usually, when I am investigating this sort of thing, it&#8217;s because somebody has sent a screen shot and asks, &#8220;Where is the code that displays this?&#8221; Tapping <kbd>Alt<\/kbd> on a screen shot doesn&#8217;t usually get you very far.<\/p>\n<p> Once you find the code that displays the dialog box or message box or whatever, you can then study the code to answer follow-up questions like &#8220;What are the conditions under which this dialog will appear?&#8221; or &#8220;Is there a setting to suppress this dialog?&#8221; <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Suppose you are working in a large or unfamiliar code base and you want to know where the code is that displays a particular dialog box or message box or something. Probably the most direct way of figuring this out is to look for the strings. Say there is a message box that asks for [&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":[26],"class_list":["post-193","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-other"],"acf":[],"blog_post_summary":"<p>Suppose you are working in a large or unfamiliar code base and you want to know where the code is that displays a particular dialog box or message box or something. Probably the most direct way of figuring this out is to look for the strings. Say there is a message box that asks for [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/193","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=193"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/193\/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=193"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=193"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=193"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}