Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Report Control
  New Posts New Posts RSS Feed - [WKND] Determine ReportRecordItem from Click Event
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

[WKND] Determine ReportRecordItem from Click Event

 Post Reply Post Reply
Author
Message
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 Topic: [WKND] Determine ReportRecordItem from Click Event
    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

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: 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

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: 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

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