CMarkupStatic hyperlink text
Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=12236
Printed Date: 13 July 2025 at 11:27am Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com
Topic: CMarkupStatic hyperlink text
Posted By: ibmldev
Subject: CMarkupStatic hyperlink text
Date Posted: 22 September 2008 at 3:42pm
Imitating Codejock sample code, I am using CMarkupStatic with markup text (simplified for this example)
<StackPanel><TextBlock>Two links <Hyperlink>Foo</Hyperlink> and <Hyperlink>Bar</Hyperlink> are embedded here</TextBlock></StackPanel>
and then call the CMarkupStatic object's method
AddHandler( CXTPMarkupHyperlink::m_pClickEvent, CreateMarkupClassDelegate( this, &MyDialogClass::OnHyperlinkClick ) );
which will call my OnHyperlinkClick() function when i click on either link. How can I tell which link was clicked? Ideally, I want to get the content text "Foo" or "Bar" inside OnHyperlinkClick() for processing.
I saw a post about this here, but the so-called solution does not contain valid code. Can someone post exactly some modified code to extract the content string of the clicked hyperlink?
|
Replies:
Posted By: BerntK
Date Posted: 22 September 2008 at 4:56pm
Hi,
First add Tag='StringToGet' to markup like
<StackPanel><TextBlock>Two links
<Hyperlink Tag = 'First'>Foo</Hyperlink> and
<Hyperlink Tag='Second'>Bar</Hyperlink> are embedded
here</TextBlock></StackPanel>
Then use following code; I think its from a sample...
void CTestDlg::OnHyperlinkClick(CXTPMarkupObject* pSender, CXTPMarkupRoutedEventArgs* pArgs) { if (pSender->IsKindOf(MARKUP_TYPE(CXTPMarkupHyperlink))) { CXTPMarkupString* pTag = MARKUP_DYNAMICCAST(CXTPMarkupString, ((CXTPMarkupHyperlink*)pSender)->GetTag()); if (pTag) { TRACE(_T("Tag = %ls"), (LPCWSTR)*pTag); // will be "First" or "Second" CString strTag = (LPCWSTR)*pTag; }
pArgs->SetHandled(); } }
|
Bernt
|
Posted By: barobax
Date Posted: 23 September 2008 at 7:50am
thanks
------------- (Farsi IS WRONG you must say [PARSI])
|
Posted By: ibmldev
Date Posted: 23 September 2008 at 10:34am
Bernt,
Beautiful! Thanks very much!
|
|