Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - CMarkupStatic hyperlink text
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CMarkupStatic hyperlink text

 Post Reply Post Reply
Author
Message
ibmldev View Drop Down
Groupie
Groupie


Joined: 17 October 2006
Status: Offline
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote ibmldev Quote  Post ReplyReply Direct Link To This Post Topic: CMarkupStatic hyperlink text
    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?
Back to Top
BerntK View Drop Down
Groupie
Groupie
Avatar

Joined: 15 September 2008
Status: Offline
Points: 16
Post Options Post Options   Thanks (0) Thanks(0)   Quote BerntK Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
barobax View Drop Down
Senior Member
Senior Member


Joined: 07 May 2008
Status: Offline
Points: 117
Post Options Post Options   Thanks (0) Thanks(0)   Quote barobax Quote  Post ReplyReply Direct Link To This Post Posted: 23 September 2008 at 7:50am
thanks
(Farsi IS WRONG you must say [PARSI])
Back to Top
ibmldev View Drop Down
Groupie
Groupie


Joined: 17 October 2006
Status: Offline
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote ibmldev Quote  Post ReplyReply Direct Link To This Post Posted: 23 September 2008 at 10:34am
Bernt,

Beautiful! Thanks very much!

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.156 seconds.