Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Report Control
  New Posts New Posts RSS Feed - [WORKAROUND] OLE Drag & Drop Insertion Point
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

[WORKAROUND] OLE Drag & Drop Insertion Point

 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: [WORKAROUND] OLE Drag & Drop Insertion Point
    Posted: 23 June 2009 at 9:56pm
When dragging & dropping files from Windows Explorer onto a ReportControl with OleDropMode = xtpOLEDropManual, a red line is drawn to illustrate the insertion point. Is there a built-in way to determine the reportrecord that the insert point is located at? I can perform a hit test, and then calculating against the halfway point vertically of the reportrecord if required, I just wanted to make sure I wasn't missing a built-in method.

Thanks in advance for any help.
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: 24 June 2009 at 1:28pm
Here's a workaround in lieu of any built-in method to find the insertion point (haven't discovered one yet):


Private Sub ReportControl1_OLEDragDrop(ByVal Data As XtremeReportControl.DataObject, Effect As Long, ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal y As Single)
   Dim lo_HitTest As ReportHitTestInfo
   Dim lo_InsertBefore As ReportRecord
   Dim lo_NewRec as ReportRecord
   Dim l_Top As Long
   Dim l_Left As Long
   Dim l_Right As Long
   Dim l_Bottom As Long
  
   ' Convert mouse coords to pixels  
   x = x \ Screen.TwipsPerPixelX
   y = y \ Screen.TwipsPerPixelY
  
   ' Determine what row the mouse is hovering over
   Set lo_HitTest = Me.ReportControl1.HitTest(x, y)
   If Not lo_HitTest Is Nothing Then
      If Not lo_HitTest.Row Is Nothing Then
         lo_HitTest.Row.GetRect l_Left, l_Top, l_Right, l_Bottom
         If (y - l_Top) < (l_Bottom - y) Then
            ' Insertion point is before this row
            Set lo_InsertBefore = lo_HitTest.Row.Record
         Else
            ' Insertion point is below this row
            On Error Resume Next    ' Trap error in case we are at the bottom row
            Set lo_InsertBefore = Me.ReportControl1.Records(lo_HitTest.Row.Record.Index + 1)
            On Error GoTo 0
         End If
      End If
   End If

   If lo_InsertBefore Is Nothing Then
      ' Add new row to bottom of report
      Set lo_Rec = Me.ReportControl1.Records.Add
   Else
      ' Insert new row above this record
      Set lo_Rec = Me.ReportControl1.Records.Insert(lo_InsertBefore.Index)
   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.156 seconds.