Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Controls
  New Posts New Posts RSS Feed - How to detect Mouse-Events for Markup-Control?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

How to detect Mouse-Events for Markup-Control?

 Post Reply Post Reply
Author
Message
Jebo View Drop Down
Senior Member
Senior Member


Joined: 27 October 2005
Location: Germany
Status: Offline
Points: 318
Post Options Post Options   Thanks (0) Thanks(0)   Quote Jebo Quote  Post ReplyReply Direct Link To This Post Topic: How to detect Mouse-Events for Markup-Control?
    Posted: 05 December 2008 at 4:59am
Hi,

how can I detect if the user holds the mouse down or makes mousemoves on a markup-control?

Is there a way?
Back to Top
Jebo View Drop Down
Senior Member
Senior Member


Joined: 27 October 2005
Location: Germany
Status: Offline
Points: 318
Post Options Post Options   Thanks (0) Thanks(0)   Quote Jebo Quote  Post ReplyReply Direct Link To This Post Posted: 11 December 2008 at 12:54pm
PLEASE can you help!?
Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1355
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 11 December 2008 at 8:18pm
This trick seems to work:

1) Create a dummy Border object that will be the Height & Width of the MarkupLabel and give it the background colour of the underlying container.
2) Associate the Mouse events with the Border
3) Add the rest of your markup into a Container type element (e.g. StackPanel) and then set that to the Child property of the Border.

Here's an example:


Option Explicit

Public Sub MarkupLabelEnter(ByVal Sender As MarkupObject, ByVal Args As MarkupRoutedEventArgs)
   Debug.Print "Enter" & Rnd
End Sub
Public Sub MarkupLabelLeave(ByVal Sender As MarkupObject, ByVal Args As MarkupRoutedEventArgs)
    Debug.Print "Leave" & Rnd
End Sub

Public Sub MarkupLabelMouseMove(ByVal Sender As MarkupObject, ByVal Args As MarkupRoutedEventArgs)
    Debug.Print "Move" & Rnd
End Sub

Private Sub Form_Load()
   Dim lo_Context As MarkupContext
   Set lo_Context = MarkupLabel1.MarkupContext
  
   Dim lo_Border As MarkupBorder
   Dim lo_Container As MarkupStackPanel
   Dim lo_Text1 As MarkupTextBlock
   Dim lo_Text2 As MarkupTextBlock
  
   Set lo_Border = lo_Context.Parse("<Border Width='Auto' Height='Auto'></Border>")
   With lo_Border
      .AddHandler .MouseEnterEvent, "MarkupLabelEnter"
      .AddHandler .MouseLeaveEvent, "MarkupLabelLeave"
      .AddHandler .MouseMoveEvent, "MarkupLabelMouseMove"
      .Background = lo_Context.CreateSolidBrush(Me.MarkupLabel1.Parent.BackColor)
   End With
  
   Set lo_Container = lo_Context.CreateObject("StackPanel")
  
   Set lo_Text1 = lo_Context.CreateObject("TextBlock")
   With lo_Text1
      .Background = lo_Context.CreateSolidBrush(vbWhite)
      .Text = "Object above mouse event lo_Border object shouldn't block events."
   End With
  
   Set lo_Text2 = lo_Context.CreateObject("TextBlock")
   With lo_Text2
      .Background = lo_Context.CreateSolidBrush(vbGreen)
      .Text = "Another Object above mouse event lo_Border object shouldn't block events."
   End With
  
   lo_Container.Children.Add lo_Text1
   lo_Container.Children.Add lo_Text2
  
   Set lo_Border.Child = lo_Container
  
   Set MarkupLabel1.MarkupUIElement = lo_Border
   lo_Context.SetHandler Me
End Sub


What I don't know is if the MouseMoveEvent exposes the X & Y coordinates of the mouse (and if so, I don't know how to retrieve that information). You might have to get the mouse position using the API and convert it to appropriate coordinates relative to your form & MarkupLabel control.
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6

Back to Top
Jebo View Drop Down
Senior Member
Senior Member


Joined: 27 October 2005
Location: Germany
Status: Offline
Points: 318
Post Options Post Options   Thanks (0) Thanks(0)   Quote Jebo Quote  Post ReplyReply Direct Link To This Post Posted: 12 December 2008 at 8:25am
Realy not bad! ;-)

Thank you!!!
Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1355
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 12 December 2008 at 1:51pm
Glad to help...hacky, but it seems to work ;)
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6

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.141 seconds.