{"id":36313,"date":"2005-03-02T07:00:00","date_gmt":"2005-03-02T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2005\/03\/02\/the-scratch-window\/"},"modified":"2005-03-02T07:00:00","modified_gmt":"2005-03-02T07:00:00","slug":"the-scratch-window","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20050302-00\/?p=36313","title":{"rendered":"The scratch window"},"content":{"rendered":"<p>\nSometimes you need a quick and dirty window\nand you don&#8217;t want to\ngo through all the hassle of registering a class for it.\nFor example, you might need a window to do a brief snippet of DDE,\nor you just need a window to own a message box.\n<\/p>\n<p>\nTo save yourself the trouble of registering a class for every single\nweenie thing you might need a window for,\nyou can get lazy and register a single &#8220;scratch window&#8221; class\nand simply subclass it on an as-needed basis.\n<\/p>\n<pre>\nATOM RegisterScratchWindowClass(void)\n{\n  WNDCLASS wc = {\n        0,                              \/\/ style\n        DefWindowProc,                  \/\/ lpfnWndProc\n        0,                              \/\/ cbClsExtra\n        0,                              \/\/ cbWndExtra\n        g_hinst,                        \/\/ this file's HINSTANCE\n        NULL,                           \/\/ hIcon\n        LoadCursor(NULL, IDC_ARROW),    \/\/ hCursor\n        (HBRUSH)(COLOR_BTNFACE+1),      \/\/ hbrBackground\n        NULL,                           \/\/ lpszMenuName\n        TEXT(\"Scratch\"),                \/\/ lpszClassName\n  };\n  return RegisterClass(&amp;wc);\n}\nHWND\nCreateScratchWindow(HWND hwndParent, WNDPROC wp)\n{\n  HWND hwnd;\n  hwnd = CreateWindow(TEXT(\"Scratch\"), NULL,\n                      hwndParent ? WS_CHILD : WS_OVERLAPPED,\n\t              0, 0, 0, 0, hwndParent, NULL, NULL, NULL);\n  if (hwnd) {\n    SubclassWindow(hwnd, wp);\n  }\n  return hwnd;\n}\n<\/pre>\n<p>\nNow if you need a quick one-off window, you can just create\na scratch window instead of creating a custom window class\njust to handle that specific task.\n<\/p>\n<p>\nWe&#8217;ll see the scratch window in action soon.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you need a quick and dirty window and you don&#8217;t want to go through all the hassle of registering a class for it. For example, you might need a window to do a brief snippet of DDE, or you just need a window to own a message box. To save yourself the trouble of [&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-36313","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>Sometimes you need a quick and dirty window and you don&#8217;t want to go through all the hassle of registering a class for it. For example, you might need a window to do a brief snippet of DDE, or you just need a window to own a message box. To save yourself the trouble of [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/36313","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=36313"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/36313\/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=36313"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=36313"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=36313"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}