<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="https://syndication.webwiz.net/rss_namespace/">
 <channel>
  <title>Codejock Developer Community : MFC - C++ - CWnd derived control in markup</title>
  <link>http://forum.codejock.com/</link>
  <description><![CDATA[This is an XML content feed of; Codejock Developer Community : Samples and Demo Applications : MFC - C++ - CWnd derived control in markup]]></description>
  <copyright>Copyright (c) 2006-2013 Web Wiz Forums - All Rights Reserved.</copyright>
  <pubDate>Tue, 12 May 2026 19:13:08 +0000</pubDate>
  <lastBuildDate>Wed, 28 May 2014 00:44:55 +0000</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 12.04</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>forum.codejock.com/RSS_post_feed.asp?TID=14413</WebWizForums:feedURL>
  <image>
   <title><![CDATA[Codejock Developer Community]]></title>
   <url>http://forum.codejock.com/forum_images/codejock-logo.gif</url>
   <link>http://forum.codejock.com/</link>
  </image>
  <item>
   <title><![CDATA[MFC - C++ - CWnd derived control in markup : this inScrollViewer have bug ]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=14413&amp;PID=72515&amp;title=mfc-c-cwnd-derived-control-in-markup#72515</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=8693">wywty</a><br /><strong>Subject:</strong> 14413<br /><strong>Posted:</strong> 28 May 2014 at 12:44am<br /><br />this in&nbsp;ScrollViewer have bug]]>
   </description>
   <pubDate>Wed, 28 May 2014 00:44:55 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=14413&amp;PID=72515&amp;title=mfc-c-cwnd-derived-control-in-markup#72515</guid>
  </item> 
  <item>
   <title><![CDATA[MFC - C++ - CWnd derived control in markup : Pete - your markup is wrong. In...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=14413&amp;PID=70872&amp;title=mfc-c-cwnd-derived-control-in-markup#70872</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=2967">adrien</a><br /><strong>Subject:</strong> 14413<br /><strong>Posted:</strong> 24 April 2013 at 11:54pm<br /><br />Pete - your markup is wrong. &nbsp;In the example it was<div><br></div><div><pre ="BBcode" style="line-height: 16px; width: 1094.5px; : rgb248, 248, 252;"><font face="Courier New, Courier, mono">...<br>&lt;EditBox Tag='Edit1' Width='100' Height='26'/&gt;<br>...</font></pre></div><div><br></div><div>not &lt;EditBox&gt;... &lt;/EditBox&gt;</div><div><br></div><div>If you want some default text settable from the markup, you'd need to set it as a named attribute and extract that from the markup context when it's being created I guess.</div>]]>
   </description>
   <pubDate>Wed, 24 Apr 2013 23:54:52 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=14413&amp;PID=70872&amp;title=mfc-c-cwnd-derived-control-in-markup#70872</guid>
  </item> 
  <item>
   <title><![CDATA[MFC - C++ - CWnd derived control in markup : Hi, I tried this and could not...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=14413&amp;PID=67525&amp;title=mfc-c-cwnd-derived-control-in-markup#67525</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=7313">pdhammond</a><br /><strong>Subject:</strong> 14413<br /><strong>Posted:</strong> 01 February 2012 at 5:54am<br /><br />Hi, I tried this and could not get it to work. I expect this is my not understanding Code Jock idioms, and it's been a long time since I used MFC too. <br><br>Using this XAML:<br>&lt;Page<br>&nbsp; xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"<br>&nbsp; xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt;<br><br>&lt;EditBox&gt;Enter something...&lt;/EditBox&gt;<br>&lt;/Page&gt;<br><br>I get this error:<br>Cannot convert the string 'Enter something...' into a 'MarkupEdit' object. Line 5, position 38<br><br>One thing I was particulalry confused about was where the AddHandler call is supposed to go. Can someone point me to some good intrudcutory documentation on this idiom?<br><br>Thanks,<br>Pete.<br>]]>
   </description>
   <pubDate>Wed, 01 Feb 2012 05:54:38 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=14413&amp;PID=67525&amp;title=mfc-c-cwnd-derived-control-in-markup#67525</guid>
  </item> 
  <item>
   <title><![CDATA[MFC - C++ - CWnd derived control in markup : Hi! and how to make the edit control...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=14413&amp;PID=58296&amp;title=mfc-c-cwnd-derived-control-in-markup#58296</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=5705">nemmartins</a><br /><strong>Subject:</strong> 14413<br /><strong>Posted:</strong> 02 May 2010 at 6:07pm<br /><br />Hi! and how to make the edit control to have the same behavior as other controls, i.e., automatic resize, etc?<br><br><br>]]>
   </description>
   <pubDate>Sun, 02 May 2010 18:07:10 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=14413&amp;PID=58296&amp;title=mfc-c-cwnd-derived-control-in-markup#58296</guid>
  </item> 
  <item>
   <title><![CDATA[MFC - C++ - CWnd derived control in markup : Hi Alina!  In VB it is not possible...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=14413&amp;PID=50388&amp;title=mfc-c-cwnd-derived-control-in-markup#50388</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=3733">Krog</a><br /><strong>Subject:</strong> 14413<br /><strong>Posted:</strong> 27 June 2009 at 6:32am<br /><br />Hi Alina!<br /><br />In VB it is not possible :(]]>
   </description>
   <pubDate>Sat, 27 Jun 2009 06:32:51 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=14413&amp;PID=50388&amp;title=mfc-c-cwnd-derived-control-in-markup#50388</guid>
  </item> 
  <item>
   <title><![CDATA[MFC - C++ - CWnd derived control in markup : How can I create edit box markup...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=14413&amp;PID=49634&amp;title=mfc-c-cwnd-derived-control-in-markup#49634</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=4582">Alina</a><br /><strong>Subject:</strong> 14413<br /><strong>Posted:</strong> 04 June 2009 at 6:57am<br /><br />How can I create edit box markup in Visual Basic?<br>Please help!<br>Thank you!<br><br>]]>
   </description>
   <pubDate>Thu, 04 Jun 2009 06:57:24 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=14413&amp;PID=49634&amp;title=mfc-c-cwnd-derived-control-in-markup#49634</guid>
  </item> 
  <item>
   <title><![CDATA[MFC - C++ - CWnd derived control in markup :  I would like to present the...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=14413&amp;PID=49470&amp;title=mfc-c-cwnd-derived-control-in-markup#49470</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=2152">gorski</a><br /><strong>Subject:</strong> 14413<br /><strong>Posted:</strong> 29 May 2009 at 5:39am<br /><br />I would like to present the way you can create your own XAML tag and put CWnd derived control inside markup. In my exaple I create edit box markup.<br><br>All you have to do is to create a class derived from CXTPMarkupFrameworkElement, register a new markup type and register some events, so you can interact with the control.<br><br>MarkupEdit.h<br><table width="99%"><tr><td><pre class="BBcode"><br><font face="Courier New, Courier, mono">#pragma once<br>class MarkupEdit : public CXTPMarkupFrameworkElement<br>{<br>&nbsp;&nbsp;&nbsp; DECLARE_MARKUPCLASS(MarkupEdit)<br><br>public:<br>&nbsp;&nbsp;&nbsp; virtual CSize MeasureOverride(CXTPMarkupDrawingContext* pDC, CSize constraint);<br>&nbsp;&nbsp;&nbsp; virtual void OnRender(CXTPMarkupDrawingContext* pDC);<br><br>&nbsp;&nbsp;&nbsp; HWND GetEdit();&nbsp; //returns HWND of the edit box control<br><br>protected:<br>&nbsp;&nbsp;&nbsp; MarkupEdit() {}<br>&nbsp;&nbsp;&nbsp; virtual ~MarkupEdit() {}<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; void CreateControl(CRect rc);<br><br>protected:<br>&nbsp;&nbsp;&nbsp; CXTPEdit mEdit; //the control we want to put into markup<br><br>public:<br>&nbsp;&nbsp;&nbsp; static CXTPMarkupRoutedEvent* m_pCreateEvent; //an event we want to fire after the control is created</font><br><font face="Courier New, Courier, mono">};</font><br></pre></td></tr></table><br><br>MarkupEdit.cpp<br><table width="99%"><tr><td><pre class="BBcode"><br><font face="Courier New, Courier, mono">#include "stdafx.h"<br>#include "MarkupEdit.h"<br><br>CXTPMarkupRoutedEvent* MarkupEdit::m_pCreateEvent = NULL;<br><br>//This line bindes the markup control with its tag<br>IMPLEMENT_MARKUPCLASS(L"EditBox", MarkupEdit, CXTPMarkupFrameworkElement)<br><br>void MarkupEdit::RegisterMarkupClass()<br>{<br>&nbsp;&nbsp;&nbsp; //register 'Create' event<br></font><font face="Courier New, Courier, mono">&nbsp;&nbsp;&nbsp; </font><font face="Courier New, Courier, mono">m_pCreateEvent = CXTPMarkupRoutedEvent::RegisterRoutedEvent(L"Create", CXTPMarkupRoutedEvent::routingBubble, MARKUP_TYPE(MarkupEdit));<br>}<br><br>CSize MarkupEdit::MeasureOverride(CXTPMarkupDrawingContext* /*pDC*/, CSize constraint)<br>{<br>&nbsp;&nbsp;&nbsp; return constraint;<br>}<br><br>void MarkupEdit::OnRender(CXTPMarkupDrawingContext* pDC)<br>{<br>&nbsp;&nbsp;&nbsp; if (!mEdit.GetSafeHwnd())<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CRect rc = m_pMarkupContext-&gt;GetClientBoundingRect(this);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CreateControl(rc);<br>&nbsp;&nbsp;&nbsp; }<br>}<br><br>void MarkupEdit::CreateControl(CRect rc)<br>{<br>&nbsp;&nbsp;&nbsp; if (m_pMarkupContext)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CWnd* wnd = CWnd::FromHandle(m_pMarkupContext-&gt;m_hContextWnd);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (wnd)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!mEdit.GetSafeHwnd())<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mEdit.Create(ES_LEFT | ES_AUTOHSCROLL | WS_VISIBLE | WS_CHILD | WS_BORDER,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rc, wnd, 0);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mEdit.SetFont(&amp;XTAuxData().font);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //fire 'Create' event<br></font><font face="Courier New, Courier, mono">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font face="Courier New, Courier, mono">CXTPMarkupRoutedEventArgs e(m_pCreateEvent, this);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RaiseEvent(&amp;e);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; }<br>}<br><br>HWND MarkupEdit::GetEdit()<br>{<br>&nbsp;&nbsp;&nbsp; return mEdit.GetSafeHwnd();<br>}</font><br></pre></td></tr></table><br><br>Register new markup control:<br><table width="99%"><tr><td><pre class="BBcode"><br><font face="Courier New, Courier, mono">&nbsp;&nbsp;&nbsp; </font><font face="Courier New, Courier, mono">MarkupEdit::RegisterType();<br></font><font face="Courier New, Courier, mono"></font></pre></td></tr></table><br>You can do it for example in the constructor of CMarkupStatic class from Codejock sample.<br><br>Define method to handle control events:<br><table width="99%"><tr><td><pre class="BBcode"><br><font face="Courier New, Courier, mono"></font><font face="Courier New, Courier, mono">&nbsp;&nbsp;&nbsp; AddHandler(MarkupEdit::m_pCreateEvent, CreateMarkupClassDelegate(this, &amp;CMarkupStatic</font><font face="Courier New, Courier, mono">::OnEditCreate));<br></font><font face="Courier New, Courier, mono"></font></pre></td></tr></table><br><br>Now you can put into XAML your tag:<br><table width="99%"><tr><td><pre class="BBcode"><br><font face="Courier New, Courier, mono">...<br>&lt;EditBox Tag='Edit1' Width='100' Height='26'/&gt;<br>...</font><br></pre></td></tr></table><br><br>When the edit control is created inside markup, 'Create' event is fired and you can get the pointer or HWND of the control. If you put more edit boxes into markup, you can distighuish them by 'Tag' property.<br><table width="99%"><tr><td><pre class="BBcode"><br><font face="Courier New, Courier, mono">void Avatar::OnEditCreate(CXTPMarkupObject* pSender, CXTPMarkupRoutedEventArgs* pArgs)<br>{<br>&nbsp;&nbsp;&nbsp; if (pSender-&gt;IsKindOf(MARKUP_TYPE(MarkupEdit)))<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pArgs-&gt;SetHandled();<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CXTPMarkupString* pTag = MARKUP_DYNAMICCAST(CXTPMarkupString, ((MarkupEdit*)pSender)-&gt;GetTag());<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (pTag)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CString tag = (LPCTSTR)*pTag;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (tag == _T("Edit1"))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mEditHwnd = ((MarkupEdit*)pSender)-&gt;GetEdit();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; }<br>}</font><br></pre></td></tr></table><br><br>As long as markup exists, you can read whatever user entered into edit box.<br><table width="99%"><tr><td><pre class="BBcode"><br>&nbsp;&nbsp;&nbsp;<font face="Courier New, Courier, mono"> if (mEditHwnd)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CString text;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ::GetWindowText(mEditHwnd, text.GetBufferSetLength(128), 128);<br>&nbsp;&nbsp;&nbsp; }</font><br></pre></td></tr></table><br><br><img src="uploads/20090529_063320_editmarkup.jpg" height="214" width="367" border="0"><br>Voila <img src="http://forum.codejock.com/smileys/smiley2.gif" border="0" align="absmiddle"><br><br><font size="2">Comments, questions and improvements are welcome.</font><br>]]>
   </description>
   <pubDate>Fri, 29 May 2009 05:39:20 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=14413&amp;PID=49470&amp;title=mfc-c-cwnd-derived-control-in-markup#49470</guid>
  </item> 
 </channel>
</rss>