{"id":119,"date":"2006-12-01T14:12:14","date_gmt":"2006-12-01T12:12:14","guid":{"rendered":"https:\/\/alax.info\/blog\/119"},"modified":"2006-12-01T14:14:33","modified_gmt":"2006-12-01T12:14:33","slug":"how-to-use-native-window-classes-controls-in-resource-dialog-templates-in-atl-and-wtl","status":"publish","type":"post","link":"https:\/\/alax.info\/blog\/119","title":{"rendered":"How to use native window classes (controls) in resource dialog templates in ATL and WTL"},"content":{"rendered":"<p>Having custom controls implemented as window classes, it is convenient to use them directly in resource dialog templates. Visual Studio resource editor allow to add custom control item to dialog. This custom control has a <em>Class<\/em> property which defines window class name of the control. Should native C++ implementation of window class be registered, it can be used in dialog templates.<\/p>\n<p><img decoding=\"async\" id=\"image117\" alt=\"image101.png\" src=\"https:\/\/alax.info\/blog\/wp-content\/uploads\/2006\/12\/image101.png\" \/><\/p>\n<p><!--more--><\/p>\n<p><em>CRegisteredWindowT<\/em> template class turns window class implementation (descendant of ATL&#8217;s <em>CWindowImpl<\/em>) into registerable class. The sample project turns WTL&#8217;s <em>CHyperLinkImpl<\/em> implementation of a hyperlink control into Windows <em>WTL_HypeLinkEx<\/em> class:<\/p>\n<blockquote><p>class CHyperLinkEx :<br \/>\npublic CRegisteredWindowT ><br \/>\n{<br \/>\npublic:<br \/>\nDECLARE_WND_CLASS(_T(&#8220;WTL_HyperLinkEx&#8221;))<br \/>\n};<\/p><\/blockquote>\n<p>Before usage in a dialog template, the registration should take place at least once somewhere in the project, for example in dialog class constructor:<\/p>\n<blockquote><p>CMainDialog() throw()<br \/>\n{<br \/>\nATLVERIFY(CHyperLinkEx::Register());<br \/>\n}<\/p><\/blockquote>\n<p>The instance of the control class is accessible from the dialog class as follows:<\/p>\n<blockquote><p>LRESULT OnInitDialog(HWND, LPARAM)<br \/>\n{<br \/>\nCHyperLinkEx* pHyperLinkEx = CHyperLinkEx::FromWindow(GetDlgItem(IDC_HYPERLINK2));<br \/>\nATLASSERT(pHyperLinkEx);<\/p><\/blockquote>\n<p>The sample project illustrate usage of <em>CRegisteredWindowT<\/em> template class and hyperlink control:<\/p>\n<p><img decoding=\"async\" id=\"image118\" alt=\"image102.png\" src=\"https:\/\/alax.info\/blog\/wp-content\/uploads\/2006\/12\/image102.png\" \/><\/p>\n<p>Visual C++.NET 2003 source code can be downloaded <a id=\"p113\" title=\"scrollingpropertypage01.zip\" href=\"https:\/\/alax.info\/blog\/wp-content\/uploads\/2006\/12\/registeredwindow01.zip\">here<\/a>, compiled binary &#8211; <a id=\"p114\" href=\"https:\/\/alax.info\/blog\/wp-content\/uploads\/2006\/12\/registeredwindow01exe.zip\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Having custom controls implemented as window classes, it is convenient to use them directly in resource dialog templates. Visual Studio resource editor allow to add custom control item to dialog. This custom control has a Class property which defines window class name of the control. Should native C++ implementation of window class be registered, it&hellip; <\/p>\n<p><a class=\"moretag\" href=\"https:\/\/alax.info\/blog\/119\">Read the full article<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,13,20],"tags":[],"class_list":["post-119","post","type-post","status-publish","format-standard","hentry","category-atl","category-source","category-wtl"],"_links":{"self":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts\/119","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/comments?post=119"}],"version-history":[{"count":0,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts\/119\/revisions"}],"wp:attachment":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/media?parent=119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/categories?post=119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/tags?post=119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}