How can I recover the dialog resource ID from a dialog window handle?

Date:July 8, 2005 / year-entry #184
Tags:other
Orig Link:https://blogs.msdn.microsoft.com/oldnewthing/20050708-21/?p=34993
Comments:    4
Summary:Occasionally, I see someone ask a question like the following. I have the handle to a dialog window. How can I get the original dialog resource ID that the dialog was created from? As we saw in our in-depth discussion of how dialogs are created from dialog templates, the dialog template itself is not saved...

Occasionally, I see someone ask a question like the following.

I have the handle to a dialog window. How can I get the original dialog resource ID that the dialog was created from?

As we saw in our in-depth discussion of how dialogs are created from dialog templates, the dialog template itself is not saved anywhere. The purpose of a template is to act as the... well... "template" for creating a dialog box. Once the dialog box has been created, there is no need for the template any more. Consequently, there is no reason why the system should remember it.

Besides, if the dialog were created from a runtime-generated template, saving the original parameters would leave pointers to freed memory. Furthermore, the code that created the dialog box almost certainly modified the dialog box during its WM_INITDIALOG message processing (filling list boxes with data, maybe enabling or disabling some buttons), so the dialog box you see on screen doesn't correspond to a template anywhere.

It's like asking, "Given a plate of food, how do I recover the original cookbook and page number for the recipe?" By doing a chemical analysis of the food, you might be able to recover "a" recipe, but there is nothing in the food itself that says, "I came from The Joy of Cooking, page 253."


Comments (4)
  1. Paul Orrungroj says:

    What’s the recipe on page 253?

  2. Considering the number of editions JoC has been through, could be anything from Rabbit Stew (first, catch a rabbit) to microwave popcorn ;)

  3. Nate Silva says:

    In my edition it’s your choice of: "Creamed Chipped Beef", "Chipped Beef in Creole Sauce", "Chipped Beef in Cheese Sauce", "Chipped Beef and Sweet Potato Casserole" or "Chipped Beef or Corned Beef in Canned Soup."

  4. TC says:

    Early editions of The Joy Of Cooking only had 200 pages. The reference to page 253, exploits a well-known buffer overrun error which causes the end of each edition to be corrupted with pictures of ham sandwiches. Later editions corrected this error by expanding the number of pages to 928:

    http://www.amazon.com/exec/obidos/tg/detail/-/0026045702/ref=dp_proddesc_1/102-4684116-3275367?%5Fencoding=UTF8&n=283155&v=glance

    HTH,

    TC

Comments are closed.


*DISCLAIMER: I DO NOT OWN THIS CONTENT. If you are the owner and would like it removed, please contact me. The content herein is an archived reproduction of entries from Raymond Chen's "Old New Thing" Blog (most recent link is here). It may have slight formatting modifications for consistency and to improve readability.

WHY DID I DUPLICATE THIS CONTENT HERE? Let me first say this site has never had anything to sell and has never shown ads of any kind. I have nothing monetarily to gain by duplicating content here. Because I had made my own local copy of this content throughout the years, for ease of using tools like grep, I decided to put it online after I discovered some of the original content previously and publicly available, had disappeared approximately early to mid 2019. At the same time, I present the content in an easily accessible theme-agnostic way.

The information provided by Raymond's blog is, for all practical purposes, more authoritative on Windows Development than Microsoft's own MSDN documentation and should be considered supplemental reading to that documentation. The wealth of missing details provided by this blog that Microsoft could not or did not document about Windows over the years is vital enough, many would agree an online "backup" of these details is a necessary endeavor. Specifics include:

<-- Back to Old New Thing Archive Index