{"id":43663,"date":"2014-11-07T07:00:00","date_gmt":"2014-11-07T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2014\/11\/07\/why-does-an-attempt-to-create-a-syslink-control-in-my-plug-in-sometimes-fail\/"},"modified":"2014-11-07T07:00:00","modified_gmt":"2014-11-07T07:00:00","slug":"why-does-an-attempt-to-create-a-syslink-control-in-my-plug-in-sometimes-fail","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20141107-00\/?p=43663","title":{"rendered":"Why does an attempt to create a SysLink control in my plug-in sometimes fail?"},"content":{"rendered":"<p>A customer had written a plug-in for some application, and they found that their plug-in was unable to create a SysLink control via the <code>Create&shy;Window&shy;ExW<\/code> function. The same code in a standalone application works fine, but when the code is placed in their plug-in, the code fails.\n Debugging showed that the call to <code>Init&shy;Common&shy;Controls&shy;Ex<\/code> succeeded, but the <code>Create&shy;Window&shy;ExW<\/code> call failed with &#8220;Cannot find window class.&#8221;\n The customer is another victim of <a href=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2012\/12\/20\/10379796.aspx\"> not keeping their eye on the activation context<\/a>.\n They attached a manifest to their DLL so that the call to <code>Init&shy;Common&shy;Controls&shy;Ex<\/code> maps to the version of the common controls library that supports the SysLink control. But they did nothing to ensure that that context was active at the time they called <code>Create&shy;Window&shy;ExW<\/code>.\n The customer&#8217;s plug-in clearly falls into the case <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/bb773175%28v=vs.85%29.aspx#mmc\"> <i>Adding Visual Style Support to an Extension, Plug-in, MMC Snap-in or a DLL That Is Brought into a Process<\/i><\/a>. but they failed to follow the instructions provided therein (which boil down to &#8220;use isolation awareness&#8221;).\n From the symptoms, it appears that the host application for their plug-in does not activate a version-6 common controls manifest at the time it calls into the plug-in, which means that your attempt to create version-6 common controls will fail.<\/p>\n<p> On the other hand, the standalone application probably uses the technique given in <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/bb773175%28v=vs.85%29.aspx#no_extensions\"> <i>Using ComCtl32.dll Version 6 in an Application That Uses Only Standard Extensions<\/i><\/a>, which activates the version-6 common controls when the process starts and <i>leaves it active<\/i> for the duration of the process. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>A customer had written a plug-in for some application, and they found that their plug-in was unable to create a SysLink control via the Create&shy;Window&shy;ExW function. The same code in a standalone application works fine, but when the code is placed in their plug-in, the code fails. Debugging showed that the call to Init&shy;Common&shy;Controls&shy;Ex succeeded, [&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-43663","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>A customer had written a plug-in for some application, and they found that their plug-in was unable to create a SysLink control via the Create&shy;Window&shy;ExW function. The same code in a standalone application works fine, but when the code is placed in their plug-in, the code fails. Debugging showed that the call to Init&shy;Common&shy;Controls&shy;Ex succeeded, [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/43663","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=43663"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/43663\/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=43663"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=43663"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=43663"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}