Print Page | Close Window

[WORKAROUND] OLE Drag & Drop Insertion Point

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=14606
Printed Date: 15 November 2024 at 1:59am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: [WORKAROUND] OLE Drag & Drop Insertion Point
Posted By: jpbro
Subject: [WORKAROUND] OLE Drag & Drop Insertion Point
Date 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




Replies:
Posted By: jpbro
Date 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




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