MFC - C++ - CWnd derived control in markup |
Post Reply |
Author | |||||||
gorski
Newbie Joined: 06 July 2006 Location: Poland Status: Offline Points: 6 |
Post Options
Thanks(0)
Posted: 29 May 2009 at 5:39am |
||||||
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.
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. MarkupEdit.h
MarkupEdit.cpp
Register new markup control:
You can do it for example in the constructor of CMarkupStatic class from Codejock sample. Define method to handle control events:
Now you can put into XAML your tag:
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.
As long as markup exists, you can read whatever user entered into edit box.
Voila Comments, questions and improvements are welcome. |
|||||||
Alina
Newbie Joined: 26 September 2008 Location: Romania Status: Offline Points: 4 |
Post Options
Thanks(0)
|
||||||
How can I create edit box markup in Visual Basic?
Please help! Thank you! |
|||||||
Krog
Groupie Joined: 06 February 2008 Status: Offline Points: 100 |
Post Options
Thanks(0)
|
||||||
Hi Alina!
In VB it is not possible :( |
|||||||
Product: Xtreme SuitePro (ActiveX) version 15.2.1
Platform: Windows XP SP2 Language: Visual Basic 6 SP6 |
|||||||
nemmartins
Newbie Joined: 24 November 2009 Status: Offline Points: 1 |
Post Options
Thanks(0)
|
||||||
Hi! and how to make the edit control to have the same behavior as other controls, i.e., automatic resize, etc?
|
|||||||
pdhammond
Newbie Joined: 01 February 2012 Status: Offline Points: 1 |
Post Options
Thanks(0)
|
||||||
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.
Using this XAML: <Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <EditBox>Enter something...</EditBox> </Page> I get this error: Cannot convert the string 'Enter something...' into a 'MarkupEdit' object. Line 5, position 38 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? Thanks, Pete. |
|||||||
adrien
Senior Member Joined: 30 April 2007 Location: New Zealand Status: Offline Points: 449 |
Post Options
Thanks(0)
|
||||||
Pete - your markup is wrong. In the example it was
... not <EditBox>... </EditBox> 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.
|
|||||||
wywty
Newbie Joined: 28 April 2014 Status: Offline Points: 4 |
Post Options
Thanks(0)
|
||||||
this in ScrollViewer have bug
|
|||||||
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |