Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Markup - jumping to label
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Markup - jumping to label

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


Joined: 16 June 2008
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote mnowaczy Quote  Post ReplyReply Direct Link To This Post Topic: Markup - jumping to label
    Posted: 16 June 2008 at 9:43am
How to implement jumping to a label when I click on hyperlink (like in HTML)?

I imagine using Tag attribute to search through page but maybe there is en easier way to do it?
Any command to position on destination element (I want it to be visible at the beginning of the screen)?
Page have <ScrollViewer> of course.
Back to Top
mnowaczy View Drop Down
Groupie
Groupie


Joined: 16 June 2008
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote mnowaczy Quote  Post ReplyReply Direct Link To This Post Posted: 18 June 2008 at 6:08am
Any solution to this?
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 18 June 2008 at 6:59am
Hi,
 
 
Here some code to try
 
void CMarkupPadView::OnHyperlinkClick(CXTPMarkupObject* pSender, CXTPMarkupRoutedEventArgs* pArgs)
{
 if (pSender->IsKindOf(MARKUP_TYPE(CXTPMarkupHyperlink)))
 {
  CXTPMarkupScrollViewer* pView = MARKUP_DYNAMICCAST(CXTPMarkupScrollViewer, m_pUIElement->FindName(L"scroll"));
  CXTPMarkupUIElement* pText = MARKUP_DYNAMICCAST(CXTPMarkupUIElement, m_pUIElement->FindName(L"New"));
  if (pView && pText)
  {
   CRect rc = pText->GetMarkupContext()->GetClientBoundingRect(pView);
   CRect rc1 = pText->GetMarkupContext()->GetClientBoundingRect(pText);
   pView->SetScrollPos(SB_VERT, rc1.top - rc.top);
  }
  pArgs->SetHandled();
 }
}
 
and in markup add names "scroll" for ScrollView :
 
 <ScrollViewer x:Name="scroll"  ...
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
mnowaczy View Drop Down
Groupie
Groupie


Joined: 16 June 2008
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote mnowaczy Quote  Post ReplyReply Direct Link To This Post Posted: 18 June 2008 at 9:17am
Finding element and setting scroll position works well, but GetClientBoundingRect is private :(

I know my element is visual and scroll start from the beginning of the page so I did like this:

if (pView && pText){
   CXTPMarkupVisual* pVisual = (CXTPMarkupVisual*)pText;
   CRect rc = pVisual->GetBoundRect();
   while (pVisual != 0)
   {
      rc.OffsetRect(pVisual->GetVisualOffset());
      pVisual = pVisual->GetVisualParent();
   }
   pView->SetScrollPos(SB_VERT, rc.top);
}

When I look inside this metod it's not easy to understand it without any help. Hope you'll add Markups classes to Help soon.
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.031 seconds.