Print Page | Close Window

[WKND] Determine ReportRecordItem from Click Event

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Report Control
Forum Description: Topics Related to Codejock Report Control
URL: http://forum.codejock.com/forum_posts.asp?TID=14581
Printed Date: 15 November 2024 at 1:28am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: [WKND] Determine ReportRecordItem from Click Event
Posted By: jpbro
Subject: [WKND] Determine ReportRecordItem from Click Event
Date Posted: 20 June 2009 at 1:27pm
I'm using Markup events in ReportRecordItem captions, and everything is working great so far. For example, I have a number of rows and in each cell of one column I have a button that when clicked will call a sub in my VB6 form.

My question is, is there any way to determine the ReportRecordItem for the clicked markup button without having to provide unique subs for each button click event? I'm creating my records dynamically based on drag & drop, so multiple subs doesn't seem like a good option.

Thanks.


-------------
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6




Replies:
Posted By: jpbro
Date Posted: 20 June 2009 at 1:32pm
Sometimes just asking the question can help you think of the answer. I can assume that the focused row is the one where the button was clicked and get the record from there in my click event sub:


Me.ReportControl1.FocusedRow.Record




-------------
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6



Posted By: jpbro
Date Posted: 23 June 2009 at 8:43pm
It turns out to be a bit trickier than mentioned above because clicking markup UI elements does not change the focus to the record of the item you clicked. You will need to move the focus yourself in your markup event. So:


Private Type POINTAPI
   x As Long
   y As Long
End Type

Private Declare Function GetCursorPos Lib "user32.dll" (ByRef lpPoint As POINTAPI) As Long
Private Declare Function ScreenToClient Lib "user32.dll" (ByVal hwnd As Long, ByRef lpPoint As POINTAPI) As Long

Public Sub EditComments(Reserved1 As Object, Reserved2 As Object)
   ' This sub is called by a markup object Click event for example.
   Dim lo_Hit As ReportHitTestInfo
   Dim lt_Mouse As POINTAPI
  
   GetCursorPos lt_Mouse   'Get mouse pointer in screen coordinates
   ScreenToClient Me.ReportControl1.hwnd, lt_Mouse   ' Convert screen coords to coords relative to ReportControl position
  
   Set lo_Hit = Me.ReportControl1.HitTest(lt_Mouse.x, lt_Mouse.y)  ' Determine what report item the mouse is over
   If Not lo_Hit Is Nothing Then
      If Not lo_Hit.Row Is Nothing Then
         Set Me.ReportControl1.FocusedRow = lo_Hit.Row     ' Set the focus to the row that the mouse is over
        
         ' Do whatever you need to do here        
      End If
   End If
  
End Sub



-------------
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net